/vp_plugins/sptsd/cups/driver.h

http://cupsfilter.googlecode.com/ · C Header · 249 lines · 141 code · 46 blank · 62 comment · 2 complexity · c3aaca08cfbb84433cce8afb3f5be78c MD5 · raw file

  1. /*
  2. * "$Id: driver.h 7306 2008-02-15 00:52:38Z mike $"
  3. *
  4. * Printer driver utilities header file for CUPS.
  5. *
  6. * Copyright 2007 by Apple Inc.
  7. * Copyright 1993-2005 by Easy Software Products.
  8. *
  9. * These coded instructions, statements, and computer programs are the
  10. * property of Apple Inc. and are protected by Federal copyright
  11. * law. Distribution and use rights are outlined in the file "LICENSE.txt"
  12. * which should have been included with this file. If this file is
  13. * file is missing or damaged, see the license at "http://www.cups.org/".
  14. */
  15. #ifndef _CUPS_DRIVER_H_
  16. # define _CUPS_DRIVER_H_
  17. # ifdef __cplusplus
  18. extern "C" {
  19. # endif /* __cplusplus */
  20. /*
  21. * Include necessary headers...
  22. */
  23. # include <stdio.h>
  24. # include <stdlib.h>
  25. # include <time.h>
  26. # include <math.h>
  27. # if defined(WIN32) || defined(__EMX__)
  28. # include <io.h>
  29. # else
  30. # include <unistd.h>
  31. # include <fcntl.h>
  32. # endif /* WIN32 || __EMX__ */
  33. # include <cups/cups.h>
  34. # include <cups/raster.h>
  35. /*
  36. * Common macros...
  37. */
  38. # ifndef min
  39. # define min(a,b) ((a) < (b) ? (a) : (b))
  40. # define max(a,b) ((a) > (b) ? (a) : (b))
  41. # endif /* !min */
  42. /*
  43. * Constants...
  44. */
  45. #define CUPS_MAX_CHAN 15 /* Maximum number of color components */
  46. #define CUPS_MAX_LUT 4095 /* Maximum LUT value */
  47. #define CUPS_MAX_RGB 4 /* Maximum number of sRGB components */
  48. /*
  49. * Types/structures for the various routines.
  50. */
  51. typedef struct cups_lut_s /**** Lookup Table for Dithering ****/
  52. {
  53. short intensity; /* Adjusted intensity */
  54. short pixel; /* Output pixel value */
  55. int error; /* Error from desired value */
  56. } cups_lut_t;
  57. typedef struct cups_dither_s /**** Dithering State ****/
  58. {
  59. int width; /* Width of buffer */
  60. int row; /* Current row */
  61. int errors[96]; /* Error values */
  62. } cups_dither_t;
  63. typedef struct cups_sample_s /**** Color sample point ****/
  64. {
  65. unsigned char rgb[3]; /* sRGB values */
  66. unsigned char colors[CUPS_MAX_RGB]; /* Color values */
  67. } cups_sample_t;
  68. typedef struct cups_rgb_s /**** Color separation lookup table ****/
  69. {
  70. int cube_size; /* Size of color cube (2-N) on a side */
  71. int num_channels; /* Number of colors per sample */
  72. unsigned char ****colors; /* 4-D array of sample values */
  73. int cube_index[256]; /* Index into cube for a given sRGB value */
  74. int cube_mult[256]; /* Multiplier value for a given sRGB value */
  75. int cache_init; /* Are cached values initialized? */
  76. unsigned char black[CUPS_MAX_RGB]; /* Cached black (sRGB = 0,0,0) */
  77. unsigned char white[CUPS_MAX_RGB]; /* Cached white (sRGB = 255,255,255) */
  78. } cups_rgb_t;
  79. typedef struct cups_cmyk_s /**** Simple CMYK lookup table ****/
  80. {
  81. unsigned char black_lut[256]; /* Black generation LUT */
  82. unsigned char color_lut[256]; /* Color removal LUT */
  83. int ink_limit; /* Ink limit */
  84. int num_channels; /* Number of components */
  85. short *channels[CUPS_MAX_CHAN];
  86. /* Lookup tables */
  87. } cups_cmyk_t;
  88. /*
  89. * Globals...
  90. */
  91. extern const unsigned char
  92. cups_srgb_lut[256];
  93. /* sRGB gamma lookup table */
  94. extern const unsigned char
  95. cups_scmy_lut[256];
  96. /* sRGB gamma lookup table (inverted) */
  97. /*
  98. * Prototypes...
  99. */
  100. /*
  101. * Attribute function...
  102. */
  103. extern ppd_attr_t *cupsFindAttr(ppd_file_t *ppd, const char *name,
  104. const char *colormodel,
  105. const char *media,
  106. const char *resolution,
  107. char *spec, int specsize);
  108. /*
  109. * Byte checking functions...
  110. */
  111. extern int cupsCheckBytes(const unsigned char *, int);
  112. extern int cupsCheckValue(const unsigned char *, int,
  113. const unsigned char);
  114. /*
  115. * Dithering functions...
  116. */
  117. extern void cupsDitherLine(cups_dither_t *d, const cups_lut_t *lut,
  118. const short *data, int num_channels,
  119. unsigned char *p);
  120. extern cups_dither_t *cupsDitherNew(int width);
  121. extern void cupsDitherDelete(cups_dither_t *);
  122. /*
  123. * Lookup table functions for dithering...
  124. */
  125. extern cups_lut_t *cupsLutNew(int num_vals, const float *vals);
  126. extern void cupsLutDelete(cups_lut_t *lut);
  127. extern cups_lut_t *cupsLutLoad(ppd_file_t *ppd,
  128. const char *colormodel,
  129. const char *media,
  130. const char *resolution,
  131. const char *ink);
  132. /*
  133. * Bit packing functions...
  134. */
  135. extern void cupsPackHorizontal(const unsigned char *,
  136. unsigned char *, int,
  137. const unsigned char, const int);
  138. extern void cupsPackHorizontal2(const unsigned char *,
  139. unsigned char *, int, const int);
  140. extern void cupsPackHorizontalBit(const unsigned char *,
  141. unsigned char *, int,
  142. const unsigned char,
  143. const unsigned char);
  144. extern void cupsPackVertical(const unsigned char *, unsigned char *,
  145. int, const unsigned char, const int);
  146. /*
  147. * Color separation functions...
  148. */
  149. extern void cupsRGBDelete(cups_rgb_t *rgb);
  150. extern void cupsRGBDoGray(cups_rgb_t *rgb,
  151. const unsigned char *input,
  152. unsigned char *output, int num_pixels);
  153. extern void cupsRGBDoRGB(cups_rgb_t *rgb,
  154. const unsigned char *input,
  155. unsigned char *output, int num_pixels);
  156. extern cups_rgb_t *cupsRGBLoad(ppd_file_t *ppd,
  157. const char *colormodel,
  158. const char *media,
  159. const char *resolution);
  160. extern cups_rgb_t *cupsRGBNew(int num_samples, cups_sample_t *samples,
  161. int cube_size, int num_channels);
  162. /*
  163. * CMYK separation functions...
  164. */
  165. extern cups_cmyk_t *cupsCMYKNew(int num_channels);
  166. extern void cupsCMYKDelete(cups_cmyk_t *cmyk);
  167. extern void cupsCMYKDoBlack(const cups_cmyk_t *cmyk,
  168. const unsigned char *input,
  169. short *output, int num_pixels);
  170. extern void cupsCMYKDoCMYK(const cups_cmyk_t *cmyk,
  171. const unsigned char *input,
  172. short *output, int num_pixels);
  173. extern void cupsCMYKDoGray(const cups_cmyk_t *cmyk,
  174. const unsigned char *input,
  175. short *output, int num_pixels);
  176. extern void cupsCMYKDoRGB(const cups_cmyk_t *cmyk,
  177. const unsigned char *input,
  178. short *output, int num_pixels);
  179. extern cups_cmyk_t *cupsCMYKLoad(ppd_file_t *ppd,
  180. const char *colormodel,
  181. const char *media,
  182. const char *resolution);
  183. extern void cupsCMYKSetBlack(cups_cmyk_t *cmyk,
  184. float lower, float upper);
  185. extern void cupsCMYKSetCurve(cups_cmyk_t *cmyk, int channel,
  186. int num_xypoints,
  187. const float *xypoints);
  188. extern void cupsCMYKSetGamma(cups_cmyk_t *cmyk, int channel,
  189. float gamval, float density);
  190. extern void cupsCMYKSetInkLimit(cups_cmyk_t *cmyk, float limit);
  191. extern void cupsCMYKSetLtDk(cups_cmyk_t *cmyk, int channel,
  192. float light, float dark);
  193. /*
  194. * Convenience macro for writing print data...
  195. */
  196. # define cupsWritePrintData(s,n) fwrite((s), 1, (n), stdout)
  197. # ifdef __cplusplus
  198. }
  199. # endif /* __cplusplus */
  200. #endif /* !_CUPS_DRIVER_H_ */
  201. /*
  202. * End of "$Id: driver.h 7306 2008-02-15 00:52:38Z mike $".
  203. */