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

Last change on this file since 2812 was 2812, checked in by Sam Hocevar, 12 years ago
  • Add a scale parameter to pipi_dither_ordered_ext().
  • Reimplement pipi_dither_halftone() using pipi_dither_ordered_ext().
File size: 6.8 KB
Line 
1/*
2 *  libpipi       Proper image processing implementation 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 <stdio.h>
24#include <string.h>
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32/* pipi_scan_t: this enum is a list of all possible scanning methods when
33 * parsing an image’s pixels. Not all functions support all scanning paths. */
34typedef enum
35{
36    PIPI_SCAN_RASTER = 0,
37    PIPI_SCAN_SERPENTINE = 1
38}
39pipi_scan_t;
40
41/* pipi_format_t: this enum is a list of all possible pixel formats for
42 * our internal images. RGBA32 is the most usual format when an image has
43 * just been loaded, but RGBA_F is a lot better for complex operations. */
44typedef enum
45{
46    PIPI_PIXELS_UNINITIALISED = -1,
47
48    PIPI_PIXELS_RGBA_C = 0,
49    PIPI_PIXELS_BGR_C = 1,
50    PIPI_PIXELS_RGBA_F = 2,
51    PIPI_PIXELS_Y_F = 3,
52
53    PIPI_PIXELS_MASK_C = 4,
54
55    PIPI_PIXELS_MAX = 5
56}
57pipi_format_t;
58
59
60typedef enum
61{
62    PIPI_COLOR_R = 1,
63    PIPI_COLOR_G = 2,
64    PIPI_COLOR_B = 4,
65    PIPI_COLOR_A = 8,
66    PIPI_COLOR_Y = 16
67}
68pipi_color_flag_t;
69
70struct pixel_u32
71{
72    uint8_t r, g, b, a;
73};
74struct pixel_float
75{
76    float r, g, b, a;
77};
78
79typedef struct
80{
81    union
82    {
83        struct pixel_float pixel_float;
84        struct pixel_u32   pixel_u32;
85    };
86}
87pipi_pixel_t;
88
89/* pipi_pixels_t: this structure stores a pixel view of an image. */
90typedef struct
91{
92    void *pixels;
93    int w, h, pitch, bpp;
94    size_t bytes;
95}
96pipi_pixels_t;
97
98/* pipi_image_t: the main image type */
99typedef struct pipi_image pipi_image_t;
100
101/* pipi_context_t: the processing stack */
102typedef struct pipi_context pipi_context_t;
103
104/* pipi_histogram_t: the histogram type */
105typedef struct pipi_histogram pipi_histogram_t;
106
107extern pipi_pixel_t *pipi_get_color_from_string(const char* s);
108
109
110extern pipi_context_t *pipi_create_context(void);
111extern void pipi_destroy_context(pipi_context_t *);
112extern int pipi_command(pipi_context_t *, char const *, ...);
113
114extern pipi_image_t *pipi_load(char const *);
115extern pipi_image_t *pipi_load_stock(char const *);
116extern pipi_image_t *pipi_new(int, int);
117extern pipi_image_t *pipi_copy(pipi_image_t *);
118extern void pipi_free(pipi_image_t *);
119extern void pipi_save(pipi_image_t *, const char *);
120
121extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
122extern int pipi_get_image_width(pipi_image_t *img);
123extern int pipi_get_image_height(pipi_image_t *img);
124extern int pipi_get_image_pitch(pipi_image_t *img);
125
126extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
127extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
128
129extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);
130
131extern pipi_image_t *pipi_render_random(int, int);
132extern pipi_image_t *pipi_render_bayer(int, int);
133extern pipi_image_t *pipi_render_halftone(int, int);
134
135extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *);
136extern pipi_image_t *pipi_red(pipi_image_t *);
137extern pipi_image_t *pipi_green(pipi_image_t *);
138extern pipi_image_t *pipi_blue(pipi_image_t *);
139extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
140extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
141extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
142extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
143extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
144extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
145extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
146extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
147extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
148extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
149
150extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
151extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
152extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
153                                            float, float, float, float, float);
154extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
155extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
156extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
157extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
158extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
159extern pipi_image_t *pipi_invert(pipi_image_t *);
160extern pipi_image_t *pipi_threshold(pipi_image_t *, double);
161extern pipi_image_t *pipi_hflip(pipi_image_t *);
162extern pipi_image_t *pipi_vflip(pipi_image_t *);
163extern pipi_image_t *pipi_rotate90(pipi_image_t *);
164extern pipi_image_t *pipi_rotate180(pipi_image_t *);
165extern pipi_image_t *pipi_rotate270(pipi_image_t *);
166extern pipi_image_t *pipi_median(pipi_image_t *, int);
167extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int);
168extern pipi_image_t *pipi_dilate(pipi_image_t *);
169extern pipi_image_t *pipi_erode(pipi_image_t *);
170
171extern pipi_image_t *pipi_order(pipi_image_t *);
172
173extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
174extern int pipi_flood_fill(pipi_image_t *,
175                           int, int, float, float, float, float);
176extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
177extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
178                              int , uint32_t, int);
179extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int);
180extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
181
182extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,
183                                       pipi_scan_t);
184extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
185extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *,
186                                             double, double);
187extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double);
188extern pipi_image_t *pipi_dither_random(pipi_image_t *);
189extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
190extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
191extern void pipi_dither_24to16(pipi_image_t *);
192
193extern pipi_histogram_t* pipi_new_histogram(void);
194extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int);
195extern int pipi_free_histogram(pipi_histogram_t*);
196extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int);
197
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif /* __PIPI_H__ */
204
Note: See TracBrowser for help on using the repository browser.