]> git.ipfire.org Git - thirdparty/cups.git/blob - filter/raster.h
Load cups into easysw/current.
[thirdparty/cups.git] / filter / raster.h
1 /*
2 * "$Id: raster.h 6158 2006-12-17 01:44:21Z mike $"
3 *
4 * Raster file definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 by Easy Software Products.
7 *
8 * This file is part of the CUPS Imaging library.
9 *
10 * These coded instructions, statements, and computer programs are the
11 * property of Easy Software Products and are protected by Federal
12 * copyright law. Distribution and use rights are outlined in the file
13 * "LICENSE.txt" which should have been included with this file. If this
14 * file is missing or damaged please contact Easy Software Products
15 * at:
16 *
17 * Attn: CUPS Licensing Information
18 * Easy Software Products
19 * 44141 Airport View Drive, Suite 204
20 * Hollywood, Maryland 20636 USA
21 *
22 * Voice: (301) 373-9600
23 * EMail: cups-info@cups.org
24 * WWW: http://www.cups.org
25 *
26 * This file is subject to the Apple OS-Developed Software exception.
27 */
28
29 #ifndef _CUPS_RASTER_H_
30 # define _CUPS_RASTER_H_
31
32 /*
33 * Include necessary headers...
34 */
35
36 # include <cups/cups.h>
37
38 # ifdef __cplusplus
39 extern "C" {
40 # endif /* __cplusplus */
41
42 /*
43 * Every non-PostScript printer driver that supports raster images
44 * should use the application/vnd.cups-raster image file format.
45 * Since both the PostScript RIP (pstoraster, based on GNU/GPL
46 * Ghostscript) and Image RIP (imagetoraster, located in the filter
47 * directory) use it, using this format saves you a lot of work.
48 * Also, the PostScript RIP passes any printer options that are in
49 * a PS file to your driver this way as well...
50 */
51
52 /*
53 * Constants...
54 */
55
56 # define CUPS_RASTER_SYNC 0x52615333 /* RaS3 */
57 # define CUPS_RASTER_REVSYNC 0x33536152 /* 3SaR */
58
59 # define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
60 # define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
61
62 # define CUPS_RASTER_SYNCv2 0x52615332 /* RaS2 */
63 # define CUPS_RASTER_REVSYNCv2 0x32536152 /* 2SaR */
64
65
66 /*
67 * The following definition can be used to determine if the
68 * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
69 * defined...
70 */
71
72 # define CUPS_RASTER_HAVE_COLORIMETRIC 1
73
74
75 /*
76 * Types...
77 */
78
79 typedef enum cups_adv_e /**** AdvanceMedia attribute values ****/
80 {
81 CUPS_ADVANCE_NONE = 0, /* Never advance the roll */
82 CUPS_ADVANCE_FILE = 1, /* Advance the roll after this file */
83 CUPS_ADVANCE_JOB = 2, /* Advance the roll after this job */
84 CUPS_ADVANCE_SET = 3, /* Advance the roll after this set */
85 CUPS_ADVANCE_PAGE = 4 /* Advance the roll after this page */
86 } cups_adv_t;
87
88 typedef enum cups_bool_e /**** Boolean type ****/
89 {
90 CUPS_FALSE = 0, /* Logical false */
91 CUPS_TRUE = 1 /* Logical true */
92 } cups_bool_t;
93
94 typedef enum cups_cspace_e /**** cupsColorSpace attribute values ****/
95 {
96 CUPS_CSPACE_W = 0, /* Luminance */
97 CUPS_CSPACE_RGB = 1, /* Red, green, blue */
98 CUPS_CSPACE_RGBA = 2, /* Red, green, blue, alpha */
99 CUPS_CSPACE_K = 3, /* Black */
100 CUPS_CSPACE_CMY = 4, /* Cyan, magenta, yellow */
101 CUPS_CSPACE_YMC = 5, /* Yellow, magenta, cyan */
102 CUPS_CSPACE_CMYK = 6, /* Cyan, magenta, yellow, black */
103 CUPS_CSPACE_YMCK = 7, /* Yellow, magenta, cyan, black */
104 CUPS_CSPACE_KCMY = 8, /* Black, cyan, magenta, yellow */
105 CUPS_CSPACE_KCMYcm = 9, /* Black, cyan, magenta, yellow, *
106 * light-cyan, light-magenta */
107 CUPS_CSPACE_GMCK = 10, /* Gold, magenta, yellow, black */
108 CUPS_CSPACE_GMCS = 11, /* Gold, magenta, yellow, silver */
109 CUPS_CSPACE_WHITE = 12, /* White ink (as black) */
110 CUPS_CSPACE_GOLD = 13, /* Gold foil */
111 CUPS_CSPACE_SILVER = 14, /* Silver foil */
112
113 CUPS_CSPACE_CIEXYZ = 15, /* CIE XYZ @since CUPS 1.1.19@ */
114 CUPS_CSPACE_CIELab = 16, /* CIE Lab @since CUPS 1.1.19@ */
115 CUPS_CSPACE_RGBW = 17, /* Red, green, blue, white @since CUPS 1.2@ */
116
117 CUPS_CSPACE_ICC1 = 32, /* ICC-based, 1 color @since CUPS 1.1.19@ */
118 CUPS_CSPACE_ICC2 = 33, /* ICC-based, 2 colors @since CUPS 1.1.19@ */
119 CUPS_CSPACE_ICC3 = 34, /* ICC-based, 3 colors @since CUPS 1.1.19@ */
120 CUPS_CSPACE_ICC4 = 35, /* ICC-based, 4 colors @since CUPS 1.1.19@ */
121 CUPS_CSPACE_ICC5 = 36, /* ICC-based, 5 colors @since CUPS 1.1.19@ */
122 CUPS_CSPACE_ICC6 = 37, /* ICC-based, 6 colors @since CUPS 1.1.19@ */
123 CUPS_CSPACE_ICC7 = 38, /* ICC-based, 7 colors @since CUPS 1.1.19@ */
124 CUPS_CSPACE_ICC8 = 39, /* ICC-based, 8 colors @since CUPS 1.1.19@ */
125 CUPS_CSPACE_ICC9 = 40, /* ICC-based, 9 colors @since CUPS 1.1.19@ */
126 CUPS_CSPACE_ICCA = 41, /* ICC-based, 10 colors @since CUPS 1.1.19@ */
127 CUPS_CSPACE_ICCB = 42, /* ICC-based, 11 colors @since CUPS 1.1.19@ */
128 CUPS_CSPACE_ICCC = 43, /* ICC-based, 12 colors @since CUPS 1.1.19@ */
129 CUPS_CSPACE_ICCD = 44, /* ICC-based, 13 colors @since CUPS 1.1.19@ */
130 CUPS_CSPACE_ICCE = 45, /* ICC-based, 14 colors @since CUPS 1.1.19@ */
131 CUPS_CSPACE_ICCF = 46 /* ICC-based, 15 colors @since CUPS 1.1.19@ */
132 } cups_cspace_t;
133
134 typedef enum cups_cut_e /**** CutMedia attribute values ****/
135 {
136 CUPS_CUT_NONE = 0, /* Never cut the roll */
137 CUPS_CUT_FILE = 1, /* Cut the roll after this file */
138 CUPS_CUT_JOB = 2, /* Cut the roll after this job */
139 CUPS_CUT_SET = 3, /* Cut the roll after this set */
140 CUPS_CUT_PAGE = 4 /* Cut the roll after this page */
141 } cups_cut_t;
142
143 typedef enum cups_edge_e /**** LeadingEdge attribute values ****/
144 {
145 CUPS_EDGE_TOP = 0, /* Leading edge is the top of the page */
146 CUPS_EDGE_RIGHT = 1, /* Leading edge is the right of the page */
147 CUPS_EDGE_BOTTOM = 2, /* Leading edge is the bottom of the page */
148 CUPS_EDGE_LEFT = 3 /* Leading edge is the left of the page */
149 } cups_edge_t;
150
151 typedef enum cups_jog_e /**** Jog attribute values ****/
152 {
153 CUPS_JOG_NONE = 0, /* Never move pages */
154 CUPS_JOG_FILE = 1, /* Move pages after this file */
155 CUPS_JOG_JOB = 2, /* Move pages after this job */
156 CUPS_JOG_SET = 3 /* Move pages after this set */
157 } cups_jog_t;
158
159 typedef enum cups_mode_e /**** Raster modes ****/
160 {
161 CUPS_RASTER_READ = 0, /* Open stream for reading */
162 CUPS_RASTER_WRITE = 1 /* Open stream for writing */
163 } cups_mode_t;
164
165 typedef enum cups_order_e /**** cupsColorOrder attribute values ****/
166 {
167 CUPS_ORDER_CHUNKED = 0, /* CMYK CMYK CMYK ... */
168 CUPS_ORDER_BANDED = 1, /* CCC MMM YYY KKK ... */
169 CUPS_ORDER_PLANAR = 2 /* CCC ... MMM ... YYY ... KKK ... */
170 } cups_order_t;
171
172 typedef enum cups_orient_e /**** Orientation attribute values ****/
173 {
174 CUPS_ORIENT_0 = 0, /* Don't rotate the page */
175 CUPS_ORIENT_90 = 1, /* Rotate the page counter-clockwise */
176 CUPS_ORIENT_180 = 2, /* Turn the page upside down */
177 CUPS_ORIENT_270 = 3 /* Rotate the page clockwise */
178 } cups_orient_t;
179
180
181 /*
182 * The page header structure contains the standard PostScript page device
183 * dictionary, along with some CUPS-specific parameters that are provided
184 * by the RIPs...
185 *
186 * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
187 * (from CUPS 1.2 and higher) page header, for binary compatibility.
188 */
189
190 typedef struct cups_page_header_s /**** Version 1 Page Header ****/
191 {
192 /**** Standard Page Device Dictionary String Values ****/
193 char MediaClass[64]; /* MediaClass string */
194 char MediaColor[64]; /* MediaColor string */
195 char MediaType[64]; /* MediaType string */
196 char OutputType[64]; /* OutputType string */
197
198 /**** Standard Page Device Dictionary Integer Values ****/
199 unsigned AdvanceDistance; /* AdvanceDistance value in points */
200 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
201 cups_bool_t Collate; /* Collated copies value */
202 cups_cut_t CutMedia; /* CutMedia value (see above) */
203 cups_bool_t Duplex; /* Duplexed (double-sided) value */
204 unsigned HWResolution[2]; /* Resolution in dots-per-inch */
205 unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points) */
206 cups_bool_t InsertSheet; /* InsertSheet value */
207 cups_jog_t Jog; /* Jog value (see above) */
208 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
209 unsigned Margins[2]; /* Lower-lefthand margins in points */
210 cups_bool_t ManualFeed; /* ManualFeed value */
211 unsigned MediaPosition; /* MediaPosition value */
212 unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
213 cups_bool_t MirrorPrint; /* MirrorPrint value */
214 cups_bool_t NegativePrint; /* NegativePrint value */
215 unsigned NumCopies; /* Number of copies to produce */
216 cups_orient_t Orientation; /* Orientation value (see above) */
217 cups_bool_t OutputFaceUp; /* OutputFaceUp value */
218 unsigned PageSize[2]; /* Width and length of page in points */
219 cups_bool_t Separations; /* Separations value */
220 cups_bool_t TraySwitch; /* TraySwitch value */
221 cups_bool_t Tumble; /* Tumble value */
222
223 /**** CUPS Page Device Dictionary Values ****/
224 unsigned cupsWidth; /* Width of page image in pixels */
225 unsigned cupsHeight; /* Height of page image in pixels */
226 unsigned cupsMediaType; /* Media type code */
227 unsigned cupsBitsPerColor; /* Number of bits for each color */
228 unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
229 unsigned cupsBytesPerLine; /* Number of bytes per line */
230 cups_order_t cupsColorOrder; /* Order of colors */
231 cups_cspace_t cupsColorSpace; /* True colorspace */
232 unsigned cupsCompression; /* Device compression to use */
233 unsigned cupsRowCount; /* Rows per band */
234 unsigned cupsRowFeed; /* Feed between bands */
235 unsigned cupsRowStep; /* Spacing between lines */
236 } cups_page_header_t;
237
238 /**** New in CUPS 1.2 ****/
239 typedef struct cups_page_header2_s /**** Version 2 Page Header @since CUPS 1.2@ ****/
240 {
241 /**** Standard Page Device Dictionary String Values ****/
242 char MediaClass[64]; /* MediaClass string */
243 char MediaColor[64]; /* MediaColor string */
244 char MediaType[64]; /* MediaType string */
245 char OutputType[64]; /* OutputType string */
246
247 /**** Standard Page Device Dictionary Integer Values ****/
248 unsigned AdvanceDistance; /* AdvanceDistance value in points */
249 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
250 cups_bool_t Collate; /* Collated copies value */
251 cups_cut_t CutMedia; /* CutMedia value (see above) */
252 cups_bool_t Duplex; /* Duplexed (double-sided) value */
253 unsigned HWResolution[2]; /* Resolution in dots-per-inch */
254 unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points) */
255 cups_bool_t InsertSheet; /* InsertSheet value */
256 cups_jog_t Jog; /* Jog value (see above) */
257 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
258 unsigned Margins[2]; /* Lower-lefthand margins in points */
259 cups_bool_t ManualFeed; /* ManualFeed value */
260 unsigned MediaPosition; /* MediaPosition value */
261 unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
262 cups_bool_t MirrorPrint; /* MirrorPrint value */
263 cups_bool_t NegativePrint; /* NegativePrint value */
264 unsigned NumCopies; /* Number of copies to produce */
265 cups_orient_t Orientation; /* Orientation value (see above) */
266 cups_bool_t OutputFaceUp; /* OutputFaceUp value */
267 unsigned PageSize[2]; /* Width and length of page in points */
268 cups_bool_t Separations; /* Separations value */
269 cups_bool_t TraySwitch; /* TraySwitch value */
270 cups_bool_t Tumble; /* Tumble value */
271
272 /**** CUPS Page Device Dictionary Values ****/
273 unsigned cupsWidth; /* Width of page image in pixels */
274 unsigned cupsHeight; /* Height of page image in pixels */
275 unsigned cupsMediaType; /* Media type code */
276 unsigned cupsBitsPerColor; /* Number of bits for each color */
277 unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
278 unsigned cupsBytesPerLine; /* Number of bytes per line */
279 cups_order_t cupsColorOrder; /* Order of colors */
280 cups_cspace_t cupsColorSpace; /* True colorspace */
281 unsigned cupsCompression; /* Device compression to use */
282 unsigned cupsRowCount; /* Rows per band */
283 unsigned cupsRowFeed; /* Feed between bands */
284 unsigned cupsRowStep; /* Spacing between lines */
285
286 /**** Version 2 Dictionary Values ****/
287 unsigned cupsNumColors; /* Number of colors @since CUPS 1.2@ */
288 float cupsBorderlessScalingFactor;
289 /* Scaling that was applied to page data @since CUPS 1.2@ */
290 float cupsPageSize[2]; /* Floating point PageSize (scaling *
291 * factor not applied) @since CUPS 1.2@ */
292 float cupsImagingBBox[4]; /* Floating point ImagingBoundingBox *
293 * (scaling factor not applied) @since CUPS 1.2@ */
294 unsigned cupsInteger[16]; /* User-defined integer values @since CUPS 1.2@ */
295 float cupsReal[16]; /* User-defined floating-point values @since CUPS 1.2@ */
296 char cupsString[16][64]; /* User-defined string values @since CUPS 1.2@ */
297 char cupsMarkerType[64]; /* Ink/toner type @since CUPS 1.2@ */
298 char cupsRenderingIntent[64];/* Color rendering intent @since CUPS 1.2@ */
299 char cupsPageSizeName[64]; /* PageSize name @since CUPS 1.2@ */
300 } cups_page_header2_t;
301
302 typedef struct _cups_raster_s cups_raster_t;
303 /**** Raster stream data ****/
304
305 typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
306
307
308 /*
309 * Prototypes...
310 */
311
312 extern void cupsRasterClose(cups_raster_t *r);
313 extern cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode);
314 extern unsigned cupsRasterReadHeader(cups_raster_t *r,
315 cups_page_header_t *h);
316 extern unsigned cupsRasterReadPixels(cups_raster_t *r,
317 unsigned char *p, unsigned len);
318 extern unsigned cupsRasterWriteHeader(cups_raster_t *r,
319 cups_page_header_t *h);
320 extern unsigned cupsRasterWritePixels(cups_raster_t *r,
321 unsigned char *p, unsigned len);
322
323 /**** New in CUPS 1.2 ****/
324 extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
325 ppd_file_t *ppd,
326 int num_options,
327 cups_option_t *options,
328 cups_interpret_cb_t func);
329 extern unsigned cupsRasterReadHeader2(cups_raster_t *r,
330 cups_page_header2_t *h);
331 extern unsigned cupsRasterWriteHeader2(cups_raster_t *r,
332 cups_page_header2_t *h);
333
334 # ifdef __cplusplus
335 }
336 # endif /* __cplusplus */
337
338 #endif /* !_CUPS_RASTER_H_ */
339
340 /*
341 * End of "$Id: raster.h 6158 2006-12-17 01:44:21Z mike $".
342 */