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