You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

208 line
6.9 KiB

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