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

Last change on this file since 2790 was 2790, checked in by Sam Hocevar, 14 years ago
  • Add pipi_order, to transform any image into an ordered dithering matrix.
File size: 6.0 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_RGBA_C = 0,
47    PIPI_PIXELS_BGR_C = 1,
48    PIPI_PIXELS_RGBA_F = 2,
49    PIPI_PIXELS_Y_F = 3,
50
51    PIPI_PIXELS_MASK_C = 4,
52
53    PIPI_PIXELS_MAX = 5
54}
55pipi_format_t;
56
57struct pixel_u32
58{
59    uint8_t r, g, b, a;
60};
61struct pixel_float
62{
63    float r, g, b, a;
64};
65
66typedef struct
67{
68    union
69    {
70        struct pixel_u32   pixel_u32;
71        struct pixel_float pixel_float;
72    };
73}
74pipi_pixel_t;
75
76/* pipi_pixels_t: this structure stores a pixel view of an image. */
77typedef struct
78{
79    void *pixels;
80    int w, h, pitch, bpp;
81    size_t bytes;
82}
83pipi_pixels_t;
84
85/* pipi_image_t: the main image type */
86typedef struct pipi_image pipi_image_t;
87
88/* pipi_context_t: the processing stack */
89typedef struct pipi_context pipi_context_t;
90
91
92extern pipi_context_t *pipi_create_context(void);
93extern void pipi_destroy_context(pipi_context_t *);
94extern int pipi_command(pipi_context_t *, char const *, ...);
95
96extern pipi_image_t *pipi_load(char const *);
97extern pipi_image_t *pipi_load_stock(char const *);
98extern pipi_image_t *pipi_new(int, int);
99extern pipi_image_t *pipi_copy(pipi_image_t *);
100extern void pipi_free(pipi_image_t *);
101extern void pipi_save(pipi_image_t *, const char *);
102
103extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
104extern int pipi_get_image_width(pipi_image_t *img);
105extern int pipi_get_image_height(pipi_image_t *img);
106extern int pipi_get_image_pitch(pipi_image_t *img);
107
108extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
109extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
110
111extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);
112
113extern pipi_image_t *pipi_render_random(int, int);
114extern pipi_image_t *pipi_render_bayer(int, int);
115extern pipi_image_t *pipi_render_halftone(int, int);
116
117extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *);
118extern pipi_image_t *pipi_red(pipi_image_t *);
119extern pipi_image_t *pipi_green(pipi_image_t *);
120extern pipi_image_t *pipi_blue(pipi_image_t *);
121extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
122extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
123extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
124extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
125extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
126extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
127extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
128extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
129extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
130extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
131
132extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
133extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
134extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
135                                            float, float, float, float, float);
136extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
137extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
138extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
139extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
140extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
141extern pipi_image_t *pipi_invert(pipi_image_t *);
142extern pipi_image_t *pipi_threshold(pipi_image_t *, double);
143extern pipi_image_t *pipi_hflip(pipi_image_t *);
144extern pipi_image_t *pipi_vflip(pipi_image_t *);
145extern pipi_image_t *pipi_rotate90(pipi_image_t *);
146extern pipi_image_t *pipi_rotate180(pipi_image_t *);
147extern pipi_image_t *pipi_rotate270(pipi_image_t *);
148extern pipi_image_t *pipi_median(pipi_image_t *, int);
149extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int);
150extern pipi_image_t *pipi_dilate(pipi_image_t *);
151extern pipi_image_t *pipi_erode(pipi_image_t *);
152
153extern pipi_image_t *pipi_order(pipi_image_t *);
154
155extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
156extern int pipi_flood_fill(pipi_image_t *,
157                           int, int, float, float, float, float);
158extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
159extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
160                              int , uint32_t, int);
161extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int);
162extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
163
164extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,
165                                       pipi_scan_t);
166extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
167extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double);
168extern pipi_image_t *pipi_dither_random(pipi_image_t *);
169extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
170extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
171extern void pipi_dither_24to16(pipi_image_t *);
172
173
174#ifdef __cplusplus
175}
176#endif
177
178#endif /* __PIPI_H__ */
179
Note: See TracBrowser for help on using the repository browser.