source: libpipi/trunk/pipi/pipi.h @ 2747

Last change on this file since 2747 was 2747, checked in by Sam Hocevar, 12 years ago
  • color.c: implement pipi_threshold().
File size: 4.8 KB
Line 
1/*
2 *  libpipi       Proper image processing implementation library
3 *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id$
7 *
8 *  This library is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/*
16 * pipi.h: the full libpipi public API
17 */
18
19#ifndef __PIPI_H__
20#define __PIPI_H__
21
22#include <stdio.h>
23#include <string.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30/* pipi_scan_t: this enum is a list of all possible scanning methods when
31 * parsing an image’s pixels. Not all functions support all scanning paths. */
32typedef enum
33{
34    PIPI_SCAN_RASTER = 0,
35    PIPI_SCAN_SERPENTINE = 1
36}
37pipi_scan_t;
38
39/* pipi_format_t: this enum is a list of all possible pixel formats for
40 * our internal images. RGBA32 is the most usual format when an image has
41 * just been loaded, but RGBA_F is a lot better for complex operations. */
42typedef enum
43{
44    PIPI_PIXELS_UNINITIALISED = -1,
45
46    PIPI_PIXELS_RGBA32 = 0,
47    PIPI_PIXELS_BGR24 = 1,
48    PIPI_PIXELS_RGBA_F = 2,
49    PIPI_PIXELS_Y_F = 3,
50
51    PIPI_PIXELS_MAX = 4
52}
53pipi_format_t;
54
55struct pixel_u32
56{
57    uint8_t r, g, b, a;
58};
59struct pixel_float
60{
61    float r, g, b, a;
62};
63
64typedef struct
65{
66    union
67    {
68        struct pixel_u32   pixel_u32;
69        struct pixel_float pixel_float;
70    };
71}
72pipi_pixel_t;
73
74/* pipi_pixels_t: this structure stores a pixel view of an image. */
75typedef struct
76{
77    void *pixels;
78    int w, h, pitch, bpp;
79    size_t bytes;
80}
81pipi_pixels_t;
82
83/* pipi_image_t: the main image type */
84typedef struct pipi_image pipi_image_t;
85
86/* pipi_context_t: the processing stack */
87typedef struct pipi_context pipi_context_t;
88
89
90extern pipi_context_t *pipi_create_context(void);
91extern void pipi_destroy_context(pipi_context_t *);
92extern int pipi_command(pipi_context_t *, char const *, ...);
93
94extern pipi_image_t *pipi_load(char const *);
95extern pipi_image_t *pipi_load_stock(char const *);
96extern pipi_image_t *pipi_new(int, int);
97extern pipi_image_t *pipi_copy(pipi_image_t *);
98extern void pipi_free(pipi_image_t *);
99extern void pipi_save(pipi_image_t *, const char *);
100
101extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
102
103extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
104extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
105
106extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);
107
108extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
109extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
110extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
111extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
112extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
113extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
114extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
115extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
116extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
117extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
118
119extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
120extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
121extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
122                                            float, float, float, float, float);
123extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
124extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
125extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
126extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
127extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
128extern pipi_image_t *pipi_invert(pipi_image_t *);
129extern pipi_image_t *pipi_threshold(pipi_image_t *, double);
130extern pipi_image_t *pipi_median(pipi_image_t *, int);
131extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int);
132extern pipi_image_t *pipi_dilate(pipi_image_t *);
133extern pipi_image_t *pipi_erode(pipi_image_t *);
134
135extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
136extern int pipi_flood_fill(pipi_image_t *,
137                           int, int, float, float, float, float);
138
139extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
140
141extern pipi_image_t *pipi_dither_floydsteinberg(pipi_image_t *, pipi_scan_t);
142extern pipi_image_t *pipi_dither_jajuni(pipi_image_t *, pipi_scan_t);
143extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
144extern pipi_image_t *pipi_dither_random(pipi_image_t *);
145extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
146extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
147extern void pipi_dither_24to16(pipi_image_t *);
148
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* __PIPI_H__ */
155
Note: See TracBrowser for help on using the repository browser.