Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

198 linhas
6.5 KiB

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