PageRenderTime 33ms CodeModel.GetById 18ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

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