| 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 |
|---|
| 34 | extern "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. */ |
|---|
| 40 | typedef enum |
|---|
| 41 | { |
|---|
| 42 | PIPI_SCAN_RASTER = 0, |
|---|
| 43 | PIPI_SCAN_SERPENTINE = 1 |
|---|
| 44 | } |
|---|
| 45 | pipi_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. */ |
|---|
| 50 | typedef 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 | } |
|---|
| 63 | pipi_format_t; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | typedef 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 | } |
|---|
| 74 | pipi_color_flag_t; |
|---|
| 75 | |
|---|
| 76 | struct pixel_u32 |
|---|
| 77 | { |
|---|
| 78 | uint8_t r, g, b, a; |
|---|
| 79 | }; |
|---|
| 80 | struct pixel_float |
|---|
| 81 | { |
|---|
| 82 | float r, g, b, a; |
|---|
| 83 | }; |
|---|
| 84 | |
|---|
| 85 | typedef struct |
|---|
| 86 | { |
|---|
| 87 | union |
|---|
| 88 | { |
|---|
| 89 | struct pixel_float pixel_float; |
|---|
| 90 | struct pixel_u32 pixel_u32; |
|---|
| 91 | }; |
|---|
| 92 | } |
|---|
| 93 | pipi_pixel_t; |
|---|
| 94 | |
|---|
| 95 | /* pipi_pixels_t: this structure stores a pixel view of an image. */ |
|---|
| 96 | typedef struct |
|---|
| 97 | { |
|---|
| 98 | void *pixels; |
|---|
| 99 | int w, h, pitch, bpp; |
|---|
| 100 | size_t bytes; |
|---|
| 101 | } |
|---|
| 102 | pipi_pixels_t; |
|---|
| 103 | |
|---|
| 104 | /* pipi_tile_t: the internal tile type */ |
|---|
| 105 | typedef struct pipi_tile pipi_tile_t; |
|---|
| 106 | |
|---|
| 107 | /* pipi_image_t: the main image type */ |
|---|
| 108 | typedef struct pipi_image pipi_image_t; |
|---|
| 109 | |
|---|
| 110 | /* pipi_sequence_t: the image sequence type */ |
|---|
| 111 | typedef struct pipi_sequence pipi_sequence_t; |
|---|
| 112 | |
|---|
| 113 | /* pipi_context_t: the processing stack */ |
|---|
| 114 | typedef struct pipi_context pipi_context_t; |
|---|
| 115 | |
|---|
| 116 | /* pipi_histogram_t: the histogram type */ |
|---|
| 117 | typedef struct pipi_histogram pipi_histogram_t; |
|---|
| 118 | |
|---|
| 119 | /* pipi_command_t: the command type */ |
|---|
| 120 | typedef struct |
|---|
| 121 | { |
|---|
| 122 | char const *name; |
|---|
| 123 | int argc; |
|---|
| 124 | } |
|---|
| 125 | pipi_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 | __extern pipi_image_t *pipi_rgb2yuv(pipi_image_t *); |
|---|
| 213 | __extern pipi_image_t *pipi_yuv2rgb(pipi_image_t *); |
|---|
| 214 | |
|---|
| 215 | __extern pipi_image_t *pipi_order(pipi_image_t *); |
|---|
| 216 | |
|---|
| 217 | __extern pipi_image_t *pipi_tile(pipi_image_t *, int, int); |
|---|
| 218 | __extern int pipi_flood_fill(pipi_image_t *, |
|---|
| 219 | int, int, float, float, float, float); |
|---|
| 220 | __extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int); |
|---|
| 221 | __extern int pipi_draw_rectangle(pipi_image_t *, int, int, int, int, uint32_t, int); |
|---|
| 222 | __extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[], |
|---|
| 223 | int , uint32_t, int); |
|---|
| 224 | __extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int); |
|---|
| 225 | __extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *); |
|---|
| 226 | |
|---|
| 227 | __extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *, |
|---|
| 228 | pipi_scan_t); |
|---|
| 229 | __extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); |
|---|
| 230 | __extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *, |
|---|
| 231 | double, double); |
|---|
| 232 | __extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double); |
|---|
| 233 | __extern pipi_image_t *pipi_dither_random(pipi_image_t *); |
|---|
| 234 | __extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t); |
|---|
| 235 | __extern pipi_image_t *pipi_dither_dbs(pipi_image_t *); |
|---|
| 236 | __extern void pipi_dither_24to16(pipi_image_t *); |
|---|
| 237 | |
|---|
| 238 | __extern pipi_histogram_t* pipi_new_histogram(void); |
|---|
| 239 | __extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int); |
|---|
| 240 | __extern int pipi_free_histogram(pipi_histogram_t*); |
|---|
| 241 | __extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int); |
|---|
| 242 | |
|---|
| 243 | __extern pipi_sequence_t *pipi_open_sequence(char const *, int, int, int, |
|---|
| 244 | int, int, int); |
|---|
| 245 | __extern int pipi_feed_sequence(pipi_sequence_t *, uint8_t const *, int, int); |
|---|
| 246 | __extern int pipi_close_sequence(pipi_sequence_t *); |
|---|
| 247 | |
|---|
| 248 | #ifdef __cplusplus |
|---|
| 249 | } |
|---|
| 250 | #endif |
|---|
| 251 | |
|---|
| 252 | #endif /* __PIPI_H__ */ |
|---|
| 253 | |
|---|