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

Last change on this file since 4696 was 4696, checked in by Sam Hocevar, 9 years ago

Implement bicubic resampling. Lacks some blurring in the pre-pass, maybe.

File size: 8.9 KB
Line 
1/*
2 *  libpipi       Pathetic image processing interface library
3 *  Copyright (c) 2004-2009 Sam Hocevar <sam@hocevar.net>
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. RGBA_U8 is the most usual format when an image has
49 * just been loaded, but RGBA_F32 is a lot better for complex operations. */
50typedef enum
51{
52    PIPI_PIXELS_UNINITIALISED = -1,
53
54    PIPI_PIXELS_RGBA_U8 = 0,
55    PIPI_PIXELS_BGR_U8 = 1,
56    PIPI_PIXELS_RGBA_F32 = 2,
57    PIPI_PIXELS_Y_F32 = 3,
58
59    PIPI_PIXELS_MASK_U8 = 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_tile_t: the internal tile type */
105typedef struct pipi_tile pipi_tile_t;
106
107/* pipi_image_t: the main image type */
108typedef struct pipi_image pipi_image_t;
109
110/* pipi_sequence_t: the image sequence type */
111typedef struct pipi_sequence pipi_sequence_t;
112
113/* pipi_context_t: the processing stack */
114typedef struct pipi_context pipi_context_t;
115
116/* pipi_histogram_t: the histogram type */
117typedef struct pipi_histogram pipi_histogram_t;
118
119/* pipi_command_t: the command type */
120typedef struct
121{
122    char const *name;
123    int argc;
124}
125pipi_command_t;
126
127__extern pipi_pixel_t *pipi_get_color_from_string(const char* s);
128
129__extern char const * pipi_get_version(void);
130
131__extern pipi_context_t *pipi_create_context(void);
132__extern void pipi_destroy_context(pipi_context_t *);
133__extern pipi_command_t const *pipi_get_command_list(void);
134__extern int pipi_command(pipi_context_t *, char const *, ...);
135
136__extern pipi_tile_t *pipi_get_tile(pipi_image_t *, int, int, int,
137                                    pipi_format_t, int);
138__extern void pipi_release_tile(pipi_image_t *, pipi_tile_t *);
139__extern pipi_tile_t *pipi_create_tile(pipi_format_t, int);
140
141__extern pipi_image_t *pipi_load(char const *);
142__extern pipi_image_t *pipi_load_stock(char const *);
143__extern pipi_image_t *pipi_new(int, int);
144__extern pipi_image_t *pipi_copy(pipi_image_t *);
145__extern void pipi_free(pipi_image_t *);
146__extern int pipi_save(pipi_image_t *, const char *);
147
148__extern void pipi_set_gamma(double);
149__extern pipi_pixels_t *pipi_get_pixels(pipi_image_t *, pipi_format_t);
150__extern void pipi_release_pixels(pipi_image_t *, pipi_pixels_t *);
151__extern void pipi_set_colorspace(pipi_image_t *, pipi_format_t);
152__extern int pipi_get_image_width(pipi_image_t *img);
153__extern int pipi_get_image_height(pipi_image_t *img);
154__extern int pipi_get_image_pitch(pipi_image_t *img);
155__extern int pipi_get_image_last_modified(pipi_image_t *img);
156__extern const char* pipi_get_format_name(int format);
157
158
159__extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
160__extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
161
162__extern pipi_image_t *pipi_resize_bresenham(pipi_image_t *, int, int);
163__extern pipi_image_t *pipi_resize_bicubic(pipi_image_t *, int, int);
164__extern pipi_image_t *pipi_crop(pipi_image_t *, int, int, int, int);
165
166__extern pipi_image_t *pipi_render_random(int, int);
167__extern pipi_image_t *pipi_render_bayer(int, int);
168__extern pipi_image_t *pipi_render_halftone(int, int);
169
170__extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *);
171__extern pipi_image_t *pipi_red(pipi_image_t *);
172__extern pipi_image_t *pipi_green(pipi_image_t *);
173__extern pipi_image_t *pipi_blue(pipi_image_t *);
174__extern pipi_image_t *pipi_blit(pipi_image_t *, pipi_image_t *, int, int);
175__extern pipi_image_t *pipi_merge(pipi_image_t *, pipi_image_t *, double);
176__extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
177__extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
178__extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
179__extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
180__extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
181__extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
182__extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
183__extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
184__extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
185__extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
186
187__extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
188__extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
189__extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
190                                            float, float, float, float, float);
191__extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
192__extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
193__extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
194__extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
195__extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
196__extern pipi_image_t *pipi_invert(pipi_image_t *);
197__extern pipi_image_t *pipi_threshold(pipi_image_t *, double);
198__extern pipi_image_t *pipi_hflip(pipi_image_t *);
199__extern pipi_image_t *pipi_vflip(pipi_image_t *);
200__extern pipi_image_t *pipi_rotate(pipi_image_t *, double);
201__extern pipi_image_t *pipi_rotate90(pipi_image_t *);
202__extern pipi_image_t *pipi_rotate180(pipi_image_t *);
203__extern pipi_image_t *pipi_rotate270(pipi_image_t *);
204__extern pipi_image_t *pipi_median(pipi_image_t *, int);
205__extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int);
206__extern pipi_image_t *pipi_dilate(pipi_image_t *);
207__extern pipi_image_t *pipi_erode(pipi_image_t *);
208__extern pipi_image_t *pipi_sine(pipi_image_t *, double, double,
209                                 double, double);
210__extern pipi_image_t *pipi_wave(pipi_image_t *, double, double,
211                                 double, double);
212
213__extern pipi_image_t *pipi_order(pipi_image_t *);
214
215__extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
216__extern int pipi_flood_fill(pipi_image_t *,
217                           int, int, float, float, float, float);
218__extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
219__extern int pipi_draw_rectangle(pipi_image_t *, int, int, int, int, uint32_t, int);
220__extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
221                              int , uint32_t, int);
222__extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int);
223__extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
224
225__extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,
226                                       pipi_scan_t);
227__extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
228__extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *,
229                                             double, double);
230__extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double);
231__extern pipi_image_t *pipi_dither_random(pipi_image_t *);
232__extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
233__extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
234__extern void pipi_dither_24to16(pipi_image_t *);
235
236__extern pipi_histogram_t* pipi_new_histogram(void);
237__extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int);
238__extern int pipi_free_histogram(pipi_histogram_t*);
239__extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int);
240
241__extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int,
242                                             int, int, int);
243__extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t const *, int, int);
244__extern int pipi_close_sequence(pipi_sequence_t *);
245
246#ifdef __cplusplus
247}
248#endif
249
250#endif /* __PIPI_H__ */
251
Note: See TracBrowser for help on using the repository browser.