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