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

Last change on this file since 2902 was 2902, checked in by Sam Hocevar, 15 years ago

Support C99 types on Win32 through the same hacks as in libcaca.

File size: 7.4 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface library
3 *  Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
4 *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org
5 *                All Rights Reserved
6 *
7 *  $Id$
8 *
9 *  This library is free software. It comes without any warranty, to
10 *  the extent permitted by applicable law. You can redistribute it
11 *  and/or modify it under the terms of the Do What The Fuck You Want
12 *  To Public License, Version 2, as published by Sam Hocevar. See
13 *  http://sam.zoy.org/wtfpl/COPYING for more details.
14 */
15
16/*
17 * pipi.h: the full libpipi public API
18 */
19
20#ifndef __PIPI_H__
21#define __PIPI_H__
22
23#include <pipi_types.h>
24
25#undef __extern
26#if defined(_DOXYGEN_SKIP_ME)
27#elif defined(_WIN32) && defined(__LIBPIPI__)
28#   define __extern extern __declspec(dllexport)
29#else
30#   define __extern extern
31#endif
32
33#ifdef __cplusplus
34extern "C"
35{
36#endif
37
38/* pipi_scan_t: this enum is a list of all possible scanning methods when
39 * parsing an image’s pixels. Not all functions support all scanning paths. */
40typedef enum
41{
42    PIPI_SCAN_RASTER = 0,
43    PIPI_SCAN_SERPENTINE = 1
44}
45pipi_scan_t;
46
47/* pipi_format_t: this enum is a list of all possible pixel formats for
48 * our internal images. RGBA32 is the most usual format when an image has
49 * just been loaded, but RGBA_F is a lot better for complex operations. */
50typedef enum
51{
52    PIPI_PIXELS_UNINITIALISED = -1,
53
54    PIPI_PIXELS_RGBA_C = 0,
55    PIPI_PIXELS_BGR_C = 1,
56    PIPI_PIXELS_RGBA_F = 2,
57    PIPI_PIXELS_Y_F = 3,
58
59    PIPI_PIXELS_MASK_C = 4,
60
61    PIPI_PIXELS_MAX = 5
62}
63pipi_format_t;
64
65
66typedef enum
67{
68    PIPI_COLOR_R = 1,
69    PIPI_COLOR_G = 2,
70    PIPI_COLOR_B = 4,
71    PIPI_COLOR_A = 8,
72    PIPI_COLOR_Y = 16
73}
74pipi_color_flag_t;
75
76struct pixel_u32
77{
78    uint8_t r, g, b, a;
79};
80struct pixel_float
81{
82    float r, g, b, a;
83};
84
85typedef struct
86{
87    union
88    {
89        struct pixel_float pixel_float;
90        struct pixel_u32   pixel_u32;
91    };
92}
93pipi_pixel_t;
94
95/* pipi_pixels_t: this structure stores a pixel view of an image. */
96typedef struct
97{
98    void *pixels;
99    int w, h, pitch, bpp;
100    size_t bytes;
101}
102pipi_pixels_t;
103
104/* pipi_image_t: the main image type */
105typedef struct pipi_image pipi_image_t;
106
107/* pipi_context_t: the processing stack */
108typedef struct pipi_context pipi_context_t;
109
110/* pipi_histogram_t: the histogram type */
111typedef struct pipi_histogram pipi_histogram_t;
112
113/* pipi_command_t: the command type */
114typedef struct
115{
116    char const *name;
117    int argc;
118}
119pipi_command_t;
120
121__extern pipi_pixel_t *pipi_get_color_from_string(const char* s);
122
123char const * pipi_get_version(void);
124
125__extern pipi_context_t *pipi_create_context(void);
126__extern void pipi_destroy_context(pipi_context_t *);
127__extern pipi_command_t const *pipi_get_command_list(void);
128__extern int pipi_command(pipi_context_t *, char const *, ...);
129
130__extern pipi_image_t *pipi_load(char const *);
131__extern pipi_image_t *pipi_load_stock(char const *);
132__extern pipi_image_t *pipi_new(int, int);
133__extern pipi_image_t *pipi_copy(pipi_image_t *);
134__extern void pipi_free(pipi_image_t *);
135__extern int pipi_save(pipi_image_t *, const char *);
136
137__extern void pipi_set_gamma(double);
138__extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
139__extern int pipi_get_image_width(pipi_image_t *img);
140__extern int pipi_get_image_height(pipi_image_t *img);
141__extern int pipi_get_image_pitch(pipi_image_t *img);
142__extern int pipi_get_image_last_modified(pipi_image_t *img);
143__extern const char* pipi_get_format_name(int format);
144
145
146__extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
147__extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
148
149__extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);
150
151__extern pipi_image_t *pipi_render_random(int, int);
152__extern pipi_image_t *pipi_render_bayer(int, int);
153__extern pipi_image_t *pipi_render_halftone(int, int);
154
155__extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *);
156__extern pipi_image_t *pipi_red(pipi_image_t *);
157__extern pipi_image_t *pipi_green(pipi_image_t *);
158__extern pipi_image_t *pipi_blue(pipi_image_t *);
159__extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
160__extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
161__extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
162__extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
163__extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
164__extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
165__extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
166__extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
167__extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
168__extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
169
170__extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
171__extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
172__extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
173                                            float, float, float, float, float);
174__extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
175__extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
176__extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
177__extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
178__extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
179__extern pipi_image_t *pipi_invert(pipi_image_t *);
180__extern pipi_image_t *pipi_threshold(pipi_image_t *, double);
181__extern pipi_image_t *pipi_hflip(pipi_image_t *);
182__extern pipi_image_t *pipi_vflip(pipi_image_t *);
183__extern pipi_image_t *pipi_rotate90(pipi_image_t *);
184__extern pipi_image_t *pipi_rotate180(pipi_image_t *);
185__extern pipi_image_t *pipi_rotate270(pipi_image_t *);
186__extern pipi_image_t *pipi_median(pipi_image_t *, int);
187__extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int);
188__extern pipi_image_t *pipi_dilate(pipi_image_t *);
189__extern pipi_image_t *pipi_erode(pipi_image_t *);
190
191__extern pipi_image_t *pipi_order(pipi_image_t *);
192
193__extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
194__extern int pipi_flood_fill(pipi_image_t *,
195                           int, int, float, float, float, float);
196__extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
197__extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
198                              int , uint32_t, int);
199__extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int);
200__extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
201
202__extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,
203                                       pipi_scan_t);
204__extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
205__extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *,
206                                             double, double);
207__extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double);
208__extern pipi_image_t *pipi_dither_random(pipi_image_t *);
209__extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
210__extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
211__extern void pipi_dither_24to16(pipi_image_t *);
212
213__extern pipi_histogram_t* pipi_new_histogram(void);
214__extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int);
215__extern int pipi_free_histogram(pipi_histogram_t*);
216__extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int);
217
218#ifdef __cplusplus
219}
220#endif
221
222#endif /* __PIPI_H__ */
223
Note: See TracBrowser for help on using the repository browser.