4 * Raster file definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 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...
27 # include <cups/cups.h>
31 # endif /* __cplusplus */
34 * Every non-PostScript printer driver that supports raster images
35 * should use the application/vnd.cups-raster image file format.
36 * Since both the PostScript RIP (pstoraster, based on GNU/GPL
37 * Ghostscript) and Image RIP (imagetoraster, located in the filter
38 * directory) use it, using this format saves you a lot of work.
39 * Also, the PostScript RIP passes any printer options that are in
40 * a PS file to your driver this way as well...
47 # define CUPS_RASTER_SYNC 0x52615333 /* RaS3 */
48 # define CUPS_RASTER_REVSYNC 0x33536152 /* 3SaR */
50 # define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
51 # define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
53 # define CUPS_RASTER_SYNCv2 0x52615332 /* RaS2 */
54 # define CUPS_RASTER_REVSYNCv2 0x32536152 /* 2SaR */
58 * The following definition can be used to determine if the
59 * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
63 # define CUPS_RASTER_HAVE_COLORIMETRIC 1
70 typedef enum cups_adv_e
/**** AdvanceMedia attribute values ****/
72 CUPS_ADVANCE_NONE
= 0, /* Never advance the roll */
73 CUPS_ADVANCE_FILE
= 1, /* Advance the roll after this file */
74 CUPS_ADVANCE_JOB
= 2, /* Advance the roll after this job */
75 CUPS_ADVANCE_SET
= 3, /* Advance the roll after this set */
76 CUPS_ADVANCE_PAGE
= 4 /* Advance the roll after this page */
79 typedef enum cups_bool_e
/**** Boolean type ****/
81 CUPS_FALSE
= 0, /* Logical false */
82 CUPS_TRUE
= 1 /* Logical true */
85 typedef enum cups_cspace_e
/**** cupsColorSpace attribute values ****/
87 CUPS_CSPACE_W
= 0, /* Luminance */
88 CUPS_CSPACE_RGB
= 1, /* Red, green, blue */
89 CUPS_CSPACE_RGBA
= 2, /* Red, green, blue, alpha */
90 CUPS_CSPACE_K
= 3, /* Black */
91 CUPS_CSPACE_CMY
= 4, /* Cyan, magenta, yellow */
92 CUPS_CSPACE_YMC
= 5, /* Yellow, magenta, cyan */
93 CUPS_CSPACE_CMYK
= 6, /* Cyan, magenta, yellow, black */
94 CUPS_CSPACE_YMCK
= 7, /* Yellow, magenta, cyan, black */
95 CUPS_CSPACE_KCMY
= 8, /* Black, cyan, magenta, yellow */
96 CUPS_CSPACE_KCMYcm
= 9, /* Black, cyan, magenta, yellow, *
97 * light-cyan, light-magenta */
98 CUPS_CSPACE_GMCK
= 10, /* Gold, magenta, yellow, black */
99 CUPS_CSPACE_GMCS
= 11, /* Gold, magenta, yellow, silver */
100 CUPS_CSPACE_WHITE
= 12, /* White ink (as black) */
101 CUPS_CSPACE_GOLD
= 13, /* Gold foil */
102 CUPS_CSPACE_SILVER
= 14, /* Silver foil */
104 CUPS_CSPACE_CIEXYZ
= 15, /* CIE XYZ @since CUPS 1.1.19/Mac OS X 10.3@ */
105 CUPS_CSPACE_CIELab
= 16, /* CIE Lab @since CUPS 1.1.19/Mac OS X 10.3@ */
106 CUPS_CSPACE_RGBW
= 17, /* Red, green, blue, white @since CUPS 1.2/Mac OS X 10.5@ */
108 CUPS_CSPACE_ICC1
= 32, /* ICC-based, 1 color @since CUPS 1.1.19/Mac OS X 10.3@ */
109 CUPS_CSPACE_ICC2
= 33, /* ICC-based, 2 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
110 CUPS_CSPACE_ICC3
= 34, /* ICC-based, 3 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
111 CUPS_CSPACE_ICC4
= 35, /* ICC-based, 4 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
112 CUPS_CSPACE_ICC5
= 36, /* ICC-based, 5 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
113 CUPS_CSPACE_ICC6
= 37, /* ICC-based, 6 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
114 CUPS_CSPACE_ICC7
= 38, /* ICC-based, 7 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
115 CUPS_CSPACE_ICC8
= 39, /* ICC-based, 8 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
116 CUPS_CSPACE_ICC9
= 40, /* ICC-based, 9 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
117 CUPS_CSPACE_ICCA
= 41, /* ICC-based, 10 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
118 CUPS_CSPACE_ICCB
= 42, /* ICC-based, 11 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
119 CUPS_CSPACE_ICCC
= 43, /* ICC-based, 12 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
120 CUPS_CSPACE_ICCD
= 44, /* ICC-based, 13 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
121 CUPS_CSPACE_ICCE
= 45, /* ICC-based, 14 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
122 CUPS_CSPACE_ICCF
= 46 /* ICC-based, 15 colors @since CUPS 1.1.19/Mac OS X 10.3@ */
125 typedef enum cups_cut_e
/**** CutMedia attribute values ****/
127 CUPS_CUT_NONE
= 0, /* Never cut the roll */
128 CUPS_CUT_FILE
= 1, /* Cut the roll after this file */
129 CUPS_CUT_JOB
= 2, /* Cut the roll after this job */
130 CUPS_CUT_SET
= 3, /* Cut the roll after this set */
131 CUPS_CUT_PAGE
= 4 /* Cut the roll after this page */
134 typedef enum cups_edge_e
/**** LeadingEdge attribute values ****/
136 CUPS_EDGE_TOP
= 0, /* Leading edge is the top of the page */
137 CUPS_EDGE_RIGHT
= 1, /* Leading edge is the right of the page */
138 CUPS_EDGE_BOTTOM
= 2, /* Leading edge is the bottom of the page */
139 CUPS_EDGE_LEFT
= 3 /* Leading edge is the left of the page */
142 typedef enum cups_jog_e
/**** Jog attribute values ****/
144 CUPS_JOG_NONE
= 0, /* Never move pages */
145 CUPS_JOG_FILE
= 1, /* Move pages after this file */
146 CUPS_JOG_JOB
= 2, /* Move pages after this job */
147 CUPS_JOG_SET
= 3 /* Move pages after this set */
150 enum cups_mode_e
/**** cupsRasterOpen modes ****/
152 CUPS_RASTER_READ
= 0, /* Open stream for reading */
153 CUPS_RASTER_WRITE
= 1, /* Open stream for writing */
154 CUPS_RASTER_WRITE_COMPRESSED
= 2 /* Open stream for compressed writing @since CUPS 1.3/Mac OS X 10.5@ */
157 typedef enum cups_mode_e cups_mode_t
; /**** cupsRasterOpen modes ****/
159 typedef enum cups_order_e
/**** cupsColorOrder attribute values ****/
161 CUPS_ORDER_CHUNKED
= 0, /* CMYK CMYK CMYK ... */
162 CUPS_ORDER_BANDED
= 1, /* CCC MMM YYY KKK ... */
163 CUPS_ORDER_PLANAR
= 2 /* CCC ... MMM ... YYY ... KKK ... */
166 typedef enum cups_orient_e
/**** Orientation attribute values ****/
168 CUPS_ORIENT_0
= 0, /* Don't rotate the page */
169 CUPS_ORIENT_90
= 1, /* Rotate the page counter-clockwise */
170 CUPS_ORIENT_180
= 2, /* Turn the page upside down */
171 CUPS_ORIENT_270
= 3 /* Rotate the page clockwise */
176 * The page header structure contains the standard PostScript page device
177 * dictionary, along with some CUPS-specific parameters that are provided
180 * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
181 * (from CUPS 1.2 and higher) page header, for binary compatibility.
184 typedef struct cups_page_header_s
/**** Version 1 page header @deprecated@ ****/
186 /**** Standard Page Device Dictionary String Values ****/
187 char MediaClass
[64]; /* MediaClass string */
188 char MediaColor
[64]; /* MediaColor string */
189 char MediaType
[64]; /* MediaType string */
190 char OutputType
[64]; /* OutputType string */
192 /**** Standard Page Device Dictionary Integer Values ****/
193 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
194 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (@link cups_adv_t@) */
195 cups_bool_t Collate
; /* Collated copies value */
196 cups_cut_t CutMedia
; /* CutMedia value (@link cups_cut_t@) */
197 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
198 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
199 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points, left, bottom, right, top) */
200 cups_bool_t InsertSheet
; /* InsertSheet value */
201 cups_jog_t Jog
; /* Jog value (@link cups_jog_t@) */
202 cups_edge_t LeadingEdge
; /* LeadingEdge value (@link cups_edge_t@) */
203 unsigned Margins
[2]; /* Lower-lefthand margins in points */
204 cups_bool_t ManualFeed
; /* ManualFeed value */
205 unsigned MediaPosition
; /* MediaPosition value */
206 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
207 cups_bool_t MirrorPrint
; /* MirrorPrint value */
208 cups_bool_t NegativePrint
; /* NegativePrint value */
209 unsigned NumCopies
; /* Number of copies to produce */
210 cups_orient_t Orientation
; /* Orientation value (@link cups_orient_t@) */
211 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
212 unsigned PageSize
[2]; /* Width and length of page in points */
213 cups_bool_t Separations
; /* Separations value */
214 cups_bool_t TraySwitch
; /* TraySwitch value */
215 cups_bool_t Tumble
; /* Tumble value */
217 /**** CUPS Page Device Dictionary Values ****/
218 unsigned cupsWidth
; /* Width of page image in pixels */
219 unsigned cupsHeight
; /* Height of page image in pixels */
220 unsigned cupsMediaType
; /* Media type code */
221 unsigned cupsBitsPerColor
; /* Number of bits for each color */
222 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
223 unsigned cupsBytesPerLine
; /* Number of bytes per line */
224 cups_order_t cupsColorOrder
; /* Order of colors */
225 cups_cspace_t cupsColorSpace
; /* True colorspace */
226 unsigned cupsCompression
; /* Device compression to use */
227 unsigned cupsRowCount
; /* Rows per band */
228 unsigned cupsRowFeed
; /* Feed between bands */
229 unsigned cupsRowStep
; /* Spacing between lines */
230 } cups_page_header_t
;
232 /**** New in CUPS 1.2 ****/
233 typedef struct cups_page_header2_s
/**** Version 2 page header @since CUPS 1.2/Mac OS X 10.5@ ****/
235 /**** Standard Page Device Dictionary String Values ****/
236 char MediaClass
[64]; /* MediaClass string */
237 char MediaColor
[64]; /* MediaColor string */
238 char MediaType
[64]; /* MediaType string */
239 char OutputType
[64]; /* OutputType string */
241 /**** Standard Page Device Dictionary Integer Values ****/
242 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
243 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (@link cups_adv_t@) */
244 cups_bool_t Collate
; /* Collated copies value */
245 cups_cut_t CutMedia
; /* CutMedia value (@link cups_cut_t@) */
246 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
247 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
248 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points, left, bottom, right, top) */
249 cups_bool_t InsertSheet
; /* InsertSheet value */
250 cups_jog_t Jog
; /* Jog value (@link cups_jog_t@) */
251 cups_edge_t LeadingEdge
; /* LeadingEdge value (@link cups_edge_t@) */
252 unsigned Margins
[2]; /* Lower-lefthand margins in points */
253 cups_bool_t ManualFeed
; /* ManualFeed value */
254 unsigned MediaPosition
; /* MediaPosition value */
255 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
256 cups_bool_t MirrorPrint
; /* MirrorPrint value */
257 cups_bool_t NegativePrint
; /* NegativePrint value */
258 unsigned NumCopies
; /* Number of copies to produce */
259 cups_orient_t Orientation
; /* Orientation value (@link cups_orient_t@) */
260 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
261 unsigned PageSize
[2]; /* Width and length of page in points */
262 cups_bool_t Separations
; /* Separations value */
263 cups_bool_t TraySwitch
; /* TraySwitch value */
264 cups_bool_t Tumble
; /* Tumble value */
266 /**** CUPS Page Device Dictionary Values ****/
267 unsigned cupsWidth
; /* Width of page image in pixels */
268 unsigned cupsHeight
; /* Height of page image in pixels */
269 unsigned cupsMediaType
; /* Media type code */
270 unsigned cupsBitsPerColor
; /* Number of bits for each color */
271 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
272 unsigned cupsBytesPerLine
; /* Number of bytes per line */
273 cups_order_t cupsColorOrder
; /* Order of colors */
274 cups_cspace_t cupsColorSpace
; /* True colorspace */
275 unsigned cupsCompression
; /* Device compression to use */
276 unsigned cupsRowCount
; /* Rows per band */
277 unsigned cupsRowFeed
; /* Feed between bands */
278 unsigned cupsRowStep
; /* Spacing between lines */
280 /**** Version 2 Dictionary Values ****/
281 unsigned cupsNumColors
; /* Number of color compoents @since CUPS 1.2/Mac OS X 10.5@ */
282 float cupsBorderlessScalingFactor
;
283 /* Scaling that was applied to page data @since CUPS 1.2/Mac OS X 10.5@ */
284 float cupsPageSize
[2]; /* Floating point PageSize (scaling *
285 * factor not applied) @since CUPS 1.2/Mac OS X 10.5@ */
286 float cupsImagingBBox
[4]; /* Floating point ImagingBoundingBox
287 * (scaling factor not applied, left,
288 * bottom, right, top) @since CUPS 1.2/Mac OS X 10.5@ */
289 unsigned cupsInteger
[16]; /* User-defined integer values @since CUPS 1.2/Mac OS X 10.5@ */
290 float cupsReal
[16]; /* User-defined floating-point values @since CUPS 1.2/Mac OS X 10.5@ */
291 char cupsString
[16][64]; /* User-defined string values @since CUPS 1.2/Mac OS X 10.5@ */
292 char cupsMarkerType
[64]; /* Ink/toner type @since CUPS 1.2/Mac OS X 10.5@ */
293 char cupsRenderingIntent
[64];/* Color rendering intent @since CUPS 1.2/Mac OS X 10.5@ */
294 char cupsPageSizeName
[64]; /* PageSize name @since CUPS 1.2/Mac OS X 10.5@ */
295 } cups_page_header2_t
;
297 typedef struct _cups_raster_s cups_raster_t
;
298 /**** Raster stream data ****/
300 typedef int (*cups_interpret_cb_t
)(cups_page_header2_t
*header
, int preferred_bits
);
301 /**** cupsRasterInterpretPPD callback function
303 * This function is called by
304 * @link cupsRasterInterpretPPD@ to
305 * validate (and update, as needed)
306 * the page header attributes. The
307 * "preferred_bits" argument provides
309 * @code cupsPreferredBitsPerColor@
310 * key from the PostScript page device
311 * dictionary and is 0 if undefined.
319 extern void cupsRasterClose(cups_raster_t
*r
);
320 extern cups_raster_t
*cupsRasterOpen(int fd
, cups_mode_t mode
);
321 extern unsigned cupsRasterReadHeader(cups_raster_t
*r
,
322 cups_page_header_t
*h
) _CUPS_DEPRECATED
;
323 extern unsigned cupsRasterReadPixels(cups_raster_t
*r
,
324 unsigned char *p
, unsigned len
);
325 extern unsigned cupsRasterWriteHeader(cups_raster_t
*r
,
326 cups_page_header_t
*h
) _CUPS_DEPRECATED
;
327 extern unsigned cupsRasterWritePixels(cups_raster_t
*r
,
328 unsigned char *p
, unsigned len
);
330 /**** New in CUPS 1.2 ****/
331 extern int cupsRasterInterpretPPD(cups_page_header2_t
*h
,
334 cups_option_t
*options
,
335 cups_interpret_cb_t func
) _CUPS_API_1_2
;
336 extern unsigned cupsRasterReadHeader2(cups_raster_t
*r
,
337 cups_page_header2_t
*h
) _CUPS_API_1_2
;
338 extern unsigned cupsRasterWriteHeader2(cups_raster_t
*r
,
339 cups_page_header2_t
*h
) _CUPS_API_1_2
;
341 /**** New in CUPS 1.3 ****/
342 extern const char *cupsRasterErrorString(void) _CUPS_API_1_3
;
346 # endif /* __cplusplus */
348 #endif /* !_CUPS_RASTER_H_ */