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