Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

151 рядки
4.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_RGBA32 = 0,
  40. PIPI_PIXELS_BGR24 = 1,
  41. PIPI_PIXELS_RGBA_F = 2,
  42. PIPI_PIXELS_Y_F = 3,
  43. PIPI_PIXELS_MAX = 4
  44. }
  45. pipi_format_t;
  46. struct pixel_u32
  47. {
  48. uint8_t r, g, b, a;
  49. };
  50. struct pixel_float
  51. {
  52. float r, g, b, a;
  53. };
  54. typedef struct
  55. {
  56. union
  57. {
  58. struct pixel_u32 pixel_u32;
  59. struct pixel_float pixel_float;
  60. };
  61. }
  62. pipi_pixel_t;
  63. /* pipi_pixels_t: this structure stores a pixel view of an image. */
  64. typedef struct
  65. {
  66. void *pixels;
  67. int w, h, pitch, bpp;
  68. size_t bytes;
  69. }
  70. pipi_pixels_t;
  71. /* pipi_image_t: the main image type */
  72. typedef struct pipi_image pipi_image_t;
  73. /* pipi_context_t: the processing stack */
  74. typedef struct pipi_context pipi_context_t;
  75. extern pipi_context_t *pipi_create_context(void);
  76. extern void pipi_destroy_context(pipi_context_t *);
  77. extern int pipi_command(pipi_context_t *, char const *, ...);
  78. extern pipi_image_t *pipi_load(char const *);
  79. extern pipi_image_t *pipi_load_stock(char const *);
  80. extern pipi_image_t *pipi_new(int, int);
  81. extern pipi_image_t *pipi_copy(pipi_image_t *);
  82. extern void pipi_free(pipi_image_t *);
  83. extern void pipi_save(pipi_image_t *, const char *);
  84. extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t);
  85. extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *);
  86. extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *);
  87. extern pipi_image_t *pipi_resize(pipi_image_t *, int, int);
  88. extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *);
  89. extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *);
  90. extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *);
  91. extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *);
  92. extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *);
  93. extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *);
  94. extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *);
  95. extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *);
  96. extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *);
  97. extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *);
  98. extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]);
  99. extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float);
  100. extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *,
  101. float, float, float, float, float);
  102. extern pipi_image_t *pipi_box_blur(pipi_image_t *, int);
  103. extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int);
  104. extern pipi_image_t *pipi_brightness(pipi_image_t *, double);
  105. extern pipi_image_t *pipi_contrast(pipi_image_t *, double);
  106. extern pipi_image_t *pipi_autocontrast(pipi_image_t *);
  107. extern pipi_image_t *pipi_invert(pipi_image_t *);
  108. extern pipi_image_t *pipi_tile(pipi_image_t *, int, int);
  109. extern int pipi_flood_fill(pipi_image_t *,
  110. int, int, float, float, float, float);
  111. extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
  112. extern pipi_image_t *pipi_dither_floydsteinberg(pipi_image_t *, pipi_scan_t);
  113. extern pipi_image_t *pipi_dither_jajuni(pipi_image_t *, pipi_scan_t);
  114. extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *);
  115. extern pipi_image_t *pipi_dither_random(pipi_image_t *);
  116. extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t);
  117. extern pipi_image_t *pipi_dither_dbs(pipi_image_t *);
  118. extern void pipi_dither_24to16(pipi_image_t *);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* __PIPI_H__ */