File: driver.h

package info (click to toggle)
cupsddk 1.2.3-5
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,488 kB
  • ctags: 1,125
  • sloc: ansic: 7,074; cpp: 5,423; makefile: 526; xml: 227; sh: 153
file content (249 lines) | stat: -rw-r--r-- 7,193 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
 * "$Id: driver.h 343 2007-07-13 19:52:48Z mike $"
 *
 *   Printer driver utilities header file for CUPS.
 *
 *   Copyright 2007 by Apple Inc.
 *   Copyright 1993-2005 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are the
 *   property of Apple Inc. and are protected by Federal copyright
 *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 *   which should have been included with this file.  If this file is
 *   file is missing or damaged, see the license at "http://www.cups.org/".
 */

#ifndef _CUPS_DRIVER_H_
#  define _CUPS_DRIVER_H_

#  ifdef __cplusplus
extern "C" {
#  endif /* __cplusplus */

/*
 * Include necessary headers...
 */

#  include <stdio.h>
#  include <stdlib.h>
#  include <time.h>
#  include <math.h>

#  if defined(WIN32) || defined(__EMX__)
#    include <io.h>
#  else
#    include <unistd.h>
#    include <fcntl.h>
#  endif /* WIN32 || __EMX__ */

#  include <cups/cups.h>
#  include <cups/raster.h>


/*
 * Common macros...
 */

#  ifndef min
#    define min(a,b)	((a) < (b) ? (a) : (b))
#    define max(a,b)	((a) > (b) ? (a) : (b))
#  endif /* !min */


/*
 * Constants...
 */

#define CUPS_MAX_CHAN	15		/* Maximum number of color components */
#define CUPS_MAX_LUT	4095		/* Maximum LUT value */
#define CUPS_MAX_RGB	4		/* Maximum number of sRGB components */


/*
 * Types/structures for the various routines.
 */

typedef struct cups_lut_s		/**** Lookup Table for Dithering ****/
{
  short		intensity;		/* Adjusted intensity */
  short		pixel;			/* Output pixel value */
  int		error;			/* Error from desired value */
} cups_lut_t;

typedef struct cups_dither_s		/**** Dithering State ****/
{
  int		width;			/* Width of buffer */
  int		row;			/* Current row */
  int		errors[96];		/* Error values */
} cups_dither_t;

typedef struct cups_sample_s		/**** Color sample point ****/
{
  unsigned char	rgb[3];			/* sRGB values */
  unsigned char	colors[CUPS_MAX_RGB];	/* Color values */
} cups_sample_t;

typedef struct cups_rgb_s		/**** Color separation lookup table ****/
{
  int		cube_size;		/* Size of color cube (2-N) on a side */
  int		num_channels;		/* Number of colors per sample */
  unsigned char	****colors;		/* 4-D array of sample values */
  int		cube_index[256];	/* Index into cube for a given sRGB value */
  int		cube_mult[256];		/* Multiplier value for a given sRGB value */
  int		cache_init;		/* Are cached values initialized? */
  unsigned char	black[CUPS_MAX_RGB];	/* Cached black (sRGB = 0,0,0) */
  unsigned char	white[CUPS_MAX_RGB];	/* Cached white (sRGB = 255,255,255) */
} cups_rgb_t;

typedef struct cups_cmyk_s		/**** Simple CMYK lookup table ****/
{
  unsigned char	black_lut[256];		/* Black generation LUT */
  unsigned char	color_lut[256];		/* Color removal LUT */
  int		ink_limit;		/* Ink limit */
  int		num_channels;		/* Number of components */
  short		*channels[CUPS_MAX_CHAN];
					/* Lookup tables */
} cups_cmyk_t;


/*
 * Globals...
 */

extern const unsigned char
			cups_srgb_lut[256];
					/* sRGB gamma lookup table */
extern const unsigned char
			cups_scmy_lut[256];
					/* sRGB gamma lookup table (inverted) */


/*
 * Prototypes...
 */

/*
 * Attribute function...
 */

extern ppd_attr_t	*cupsFindAttr(ppd_file_t *ppd, const char *name,
			              const char *colormodel,
			              const char *media,
				      const char *resolution,
				      char *spec, int specsize);
			       
/*
 * Byte checking functions...
 */

extern int		cupsCheckBytes(const unsigned char *, int);
extern int		cupsCheckValue(const unsigned char *, int,
			               const unsigned char);

/*
 * Dithering functions...
 */

extern void		cupsDitherLine(cups_dither_t *d, const cups_lut_t *lut,
			               const short *data, int num_channels,
				       unsigned char *p);
extern cups_dither_t	*cupsDitherNew(int width);
extern void		cupsDitherDelete(cups_dither_t *);

/*
 * Lookup table functions for dithering...
 */

extern cups_lut_t	*cupsLutNew(int num_vals, const float *vals);
extern void		cupsLutDelete(cups_lut_t *lut);
extern cups_lut_t	*cupsLutLoad(ppd_file_t *ppd,
			             const char *colormodel,
				     const char *media,
			             const char *resolution,
				     const char *ink);


/*
 * Bit packing functions...
 */

extern void		cupsPackHorizontal(const unsigned char *,
			                   unsigned char *, int,
					   const unsigned char, const int);
extern void		cupsPackHorizontal2(const unsigned char *,
			                    unsigned char *, int, const int);
extern void		cupsPackHorizontalBit(const unsigned char *,
			                      unsigned char *, int,
					      const unsigned char,
					      const unsigned char);
extern void		cupsPackVertical(const unsigned char *, unsigned char *,
			                 int, const unsigned char, const int);

/*
 * Color separation functions...
 */

extern void		cupsRGBDelete(cups_rgb_t *rgb);
extern void		cupsRGBDoGray(cups_rgb_t *rgb,
			              const unsigned char *input,
			              unsigned char *output, int num_pixels);
extern void		cupsRGBDoRGB(cups_rgb_t *rgb,
			             const unsigned char *input,
			             unsigned char *output, int num_pixels);
extern cups_rgb_t	*cupsRGBLoad(ppd_file_t *ppd,
			             const char *colormodel,
				     const char *media,
			             const char *resolution);
extern cups_rgb_t	*cupsRGBNew(int num_samples, cups_sample_t *samples,
			            int cube_size, int num_channels);

/*
 * CMYK separation functions...
 */

extern cups_cmyk_t	*cupsCMYKNew(int num_channels);
extern void		cupsCMYKDelete(cups_cmyk_t *cmyk);
extern void		cupsCMYKDoBlack(const cups_cmyk_t *cmyk,
			                const unsigned char *input,
			                short *output, int num_pixels);
extern void		cupsCMYKDoCMYK(const cups_cmyk_t *cmyk,
			               const unsigned char *input,
			               short *output, int num_pixels);
extern void		cupsCMYKDoGray(const cups_cmyk_t *cmyk,
			               const unsigned char *input,
			               short *output, int num_pixels);
extern void		cupsCMYKDoRGB(const cups_cmyk_t *cmyk,
			              const unsigned char *input,
			              short *output, int num_pixels);
extern cups_cmyk_t	*cupsCMYKLoad(ppd_file_t *ppd,
			              const char *colormodel,
				      const char *media,
			              const char *resolution);
extern void		cupsCMYKSetBlack(cups_cmyk_t *cmyk,
			                 float lower, float upper);
extern void		cupsCMYKSetCurve(cups_cmyk_t *cmyk, int channel,
			                 int num_xypoints,
					 const float *xypoints);
extern void		cupsCMYKSetGamma(cups_cmyk_t *cmyk, int channel,
			                 float gamval, float density);
extern void		cupsCMYKSetInkLimit(cups_cmyk_t *cmyk, float limit);
extern void		cupsCMYKSetLtDk(cups_cmyk_t *cmyk, int channel,
			                float light, float dark);


/*
 * Convenience macro for writing print data...
 */

#  define cupsWritePrintData(s,n) fwrite((s), 1, (n), stdout)

#  ifdef __cplusplus
}
#  endif /* __cplusplus */

#endif /* !_CUPS_DRIVER_H_ */

/*
 * End of "$Id: driver.h 343 2007-07-13 19:52:48Z mike $".
 */