2 * "$Id: raster.h 5671 2006-06-16 11:17:39Z mike $"
4 * Raster file definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2006 by Easy Software Products.
8 * This file is part of the CUPS Imaging library.
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
17 * Attn: CUPS Licensing Information
18 * Easy Software Products
19 * 44141 Airport View Drive, Suite 204
20 * Hollywood, Maryland 20636 USA
22 * Voice: (301) 373-9600
23 * EMail: cups-info@cups.org
24 * WWW: http://www.cups.org
26 * This code and any derivative of it may be used and distributed
27 * freely under the terms of the GNU General Public License when
28 * used with GNU/GPL Ghostscript or its derivatives. Use of the
29 * code (or any derivative of it) with software other than GNU/GPL
30 * GhostScript (or its derivatives) is governed by the CUPS license
33 * This file is subject to the Apple OS-Developed Software exception.
36 #ifndef _CUPS_RASTER_H_
37 # define _CUPS_RASTER_H_
40 * Include necessary headers...
43 # include <cups/cups.h>
47 # endif /* __cplusplus */
50 * Every non-PostScript printer driver that supports raster images
51 * should use the application/vnd.cups-raster image file format.
52 * Since both the PostScript RIP (pstoraster, based on GNU/GPL
53 * Ghostscript) and Image RIP (imagetoraster, located in the filter
54 * directory) use it, using this format saves you a lot of work.
55 * Also, the PostScript RIP passes any printer options that are in
56 * a PS file to your driver this way as well...
63 # define CUPS_RASTER_SYNC 0x52615333 /* RaS3 */
64 # define CUPS_RASTER_REVSYNC 0x33536152 /* 3SaR */
66 # define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
67 # define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
69 # define CUPS_RASTER_SYNCv2 0x52615332 /* RaS2 */
70 # define CUPS_RASTER_REVSYNCv2 0x32536152 /* 2SaR */
74 * The following definition can be used to determine if the
75 * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
79 # define CUPS_RASTER_HAVE_COLORIMETRIC 1
86 typedef enum cups_mode_e
/**** Raster modes ****/
88 CUPS_RASTER_READ
= 0, /* Open stream for reading */
89 CUPS_RASTER_WRITE
= 1 /* Open stream for writing */
92 typedef enum cups_bool_e
/**** Boolean type ****/
94 CUPS_FALSE
= 0, /* Logical false */
95 CUPS_TRUE
= 1 /* Logical true */
98 typedef enum cups_jog_e
/**** Jog attribute values ****/
100 CUPS_JOG_NONE
= 0, /* Never move pages */
101 CUPS_JOG_FILE
= 1, /* Move pages after this file */
102 CUPS_JOG_JOB
= 2, /* Move pages after this job */
103 CUPS_JOG_SET
= 3 /* Move pages after this set */
106 typedef enum cups_orient_e
/**** Orientation attribute values ****/
108 CUPS_ORIENT_0
= 0, /* Don't rotate the page */
109 CUPS_ORIENT_90
= 1, /* Rotate the page counter-clockwise */
110 CUPS_ORIENT_180
= 2, /* Turn the page upside down */
111 CUPS_ORIENT_270
= 3 /* Rotate the page clockwise */
114 typedef enum cups_cut_e
/**** CutMedia attribute values ****/
116 CUPS_CUT_NONE
= 0, /* Never cut the roll */
117 CUPS_CUT_FILE
= 1, /* Cut the roll after this file */
118 CUPS_CUT_JOB
= 2, /* Cut the roll after this job */
119 CUPS_CUT_SET
= 3, /* Cut the roll after this set */
120 CUPS_CUT_PAGE
= 4 /* Cut the roll after this page */
123 typedef enum cups_adv_e
/**** AdvanceMedia attribute values ****/
125 CUPS_ADVANCE_NONE
= 0, /* Never advance the roll */
126 CUPS_ADVANCE_FILE
= 1, /* Advance the roll after this file */
127 CUPS_ADVANCE_JOB
= 2, /* Advance the roll after this job */
128 CUPS_ADVANCE_SET
= 3, /* Advance the roll after this set */
129 CUPS_ADVANCE_PAGE
= 4 /* Advance the roll after this page */
132 typedef enum cups_edge_e
/**** LeadingEdge attribute values ****/
134 CUPS_EDGE_TOP
= 0, /* Leading edge is the top of the page */
135 CUPS_EDGE_RIGHT
= 1, /* Leading edge is the right of the page */
136 CUPS_EDGE_BOTTOM
= 2, /* Leading edge is the bottom of the page */
137 CUPS_EDGE_LEFT
= 3 /* Leading edge is the left of the page */
140 typedef enum cups_order_e
/**** cupsColorOrder attribute values ****/
142 CUPS_ORDER_CHUNKED
= 0, /* CMYK CMYK CMYK ... */
143 CUPS_ORDER_BANDED
= 1, /* CCC MMM YYY KKK ... */
144 CUPS_ORDER_PLANAR
= 2 /* CCC ... MMM ... YYY ... KKK ... */
147 typedef enum cups_cspace_e
/**** cupsColorSpace attribute values ****/
149 CUPS_CSPACE_W
= 0, /* Luminance */
150 CUPS_CSPACE_RGB
= 1, /* Red, green, blue */
151 CUPS_CSPACE_RGBA
= 2, /* Red, green, blue, alpha */
152 CUPS_CSPACE_K
= 3, /* Black */
153 CUPS_CSPACE_CMY
= 4, /* Cyan, magenta, yellow */
154 CUPS_CSPACE_YMC
= 5, /* Yellow, magenta, cyan */
155 CUPS_CSPACE_CMYK
= 6, /* Cyan, magenta, yellow, black */
156 CUPS_CSPACE_YMCK
= 7, /* Yellow, magenta, cyan, black */
157 CUPS_CSPACE_KCMY
= 8, /* Black, cyan, magenta, yellow */
158 CUPS_CSPACE_KCMYcm
= 9, /* Black, cyan, magenta, yellow, *
159 * light-cyan, light-magenta */
160 CUPS_CSPACE_GMCK
= 10, /* Gold, magenta, yellow, black */
161 CUPS_CSPACE_GMCS
= 11, /* Gold, magenta, yellow, silver */
162 CUPS_CSPACE_WHITE
= 12, /* White ink (as black) */
163 CUPS_CSPACE_GOLD
= 13, /* Gold foil */
164 CUPS_CSPACE_SILVER
= 14, /* Silver foil */
166 CUPS_CSPACE_CIEXYZ
= 15, /* CIE XYZ @since CUPS 1.1.19@ */
167 CUPS_CSPACE_CIELab
= 16, /* CIE Lab @since CUPS 1.1.19@ */
168 CUPS_CSPACE_RGBW
= 17, /* Red, green, blue, white @since CUPS 1.2@ */
170 CUPS_CSPACE_ICC1
= 32, /* ICC-based, 1 color @since CUPS 1.1.19@ */
171 CUPS_CSPACE_ICC2
= 33, /* ICC-based, 2 colors @since CUPS 1.1.19@ */
172 CUPS_CSPACE_ICC3
= 34, /* ICC-based, 3 colors @since CUPS 1.1.19@ */
173 CUPS_CSPACE_ICC4
= 35, /* ICC-based, 4 colors @since CUPS 1.1.19@ */
174 CUPS_CSPACE_ICC5
= 36, /* ICC-based, 5 colors @since CUPS 1.1.19@ */
175 CUPS_CSPACE_ICC6
= 37, /* ICC-based, 6 colors @since CUPS 1.1.19@ */
176 CUPS_CSPACE_ICC7
= 38, /* ICC-based, 7 colors @since CUPS 1.1.19@ */
177 CUPS_CSPACE_ICC8
= 39, /* ICC-based, 8 colors @since CUPS 1.1.19@ */
178 CUPS_CSPACE_ICC9
= 40, /* ICC-based, 9 colors @since CUPS 1.1.19@ */
179 CUPS_CSPACE_ICCA
= 41, /* ICC-based, 10 colors @since CUPS 1.1.19@ */
180 CUPS_CSPACE_ICCB
= 42, /* ICC-based, 11 colors @since CUPS 1.1.19@ */
181 CUPS_CSPACE_ICCC
= 43, /* ICC-based, 12 colors @since CUPS 1.1.19@ */
182 CUPS_CSPACE_ICCD
= 44, /* ICC-based, 13 colors @since CUPS 1.1.19@ */
183 CUPS_CSPACE_ICCE
= 45, /* ICC-based, 14 colors @since CUPS 1.1.19@ */
184 CUPS_CSPACE_ICCF
= 46 /* ICC-based, 15 colors @since CUPS 1.1.19@ */
189 * The page header structure contains the standard PostScript page device
190 * dictionary, along with some CUPS-specific parameters that are provided
193 * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
194 * (from CUPS 1.2 and higher) page header, for binary compatibility.
197 typedef struct cups_page_header_s
/**** Version 1 Page Header ****/
199 /**** Standard Page Device Dictionary String Values ****/
200 char MediaClass
[64]; /* MediaClass string */
201 char MediaColor
[64]; /* MediaColor string */
202 char MediaType
[64]; /* MediaType string */
203 char OutputType
[64]; /* OutputType string */
205 /**** Standard Page Device Dictionary Integer Values ****/
206 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
207 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (see above) */
208 cups_bool_t Collate
; /* Collated copies value */
209 cups_cut_t CutMedia
; /* CutMedia value (see above) */
210 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
211 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
212 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points) */
213 cups_bool_t InsertSheet
; /* InsertSheet value */
214 cups_jog_t Jog
; /* Jog value (see above) */
215 cups_edge_t LeadingEdge
; /* LeadingEdge value (see above) */
216 unsigned Margins
[2]; /* Lower-lefthand margins in points */
217 cups_bool_t ManualFeed
; /* ManualFeed value */
218 unsigned MediaPosition
; /* MediaPosition value */
219 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
220 cups_bool_t MirrorPrint
; /* MirrorPrint value */
221 cups_bool_t NegativePrint
; /* NegativePrint value */
222 unsigned NumCopies
; /* Number of copies to produce */
223 cups_orient_t Orientation
; /* Orientation value (see above) */
224 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
225 unsigned PageSize
[2]; /* Width and length of page in points */
226 cups_bool_t Separations
; /* Separations value */
227 cups_bool_t TraySwitch
; /* TraySwitch value */
228 cups_bool_t Tumble
; /* Tumble value */
230 /**** CUPS Page Device Dictionary Values ****/
231 unsigned cupsWidth
; /* Width of page image in pixels */
232 unsigned cupsHeight
; /* Height of page image in pixels */
233 unsigned cupsMediaType
; /* Media type code */
234 unsigned cupsBitsPerColor
; /* Number of bits for each color */
235 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
236 unsigned cupsBytesPerLine
; /* Number of bytes per line */
237 cups_order_t cupsColorOrder
; /* Order of colors */
238 cups_cspace_t cupsColorSpace
; /* True colorspace */
239 unsigned cupsCompression
; /* Device compression to use */
240 unsigned cupsRowCount
; /* Rows per band */
241 unsigned cupsRowFeed
; /* Feed between bands */
242 unsigned cupsRowStep
; /* Spacing between lines */
243 } cups_page_header_t
;
245 /**** New in CUPS 1.2 ****/
246 typedef struct cups_page_header2_s
/**** Version 2 Page Header @since CUPS 1.2@ ****/
248 /**** Standard Page Device Dictionary String Values ****/
249 char MediaClass
[64]; /* MediaClass string */
250 char MediaColor
[64]; /* MediaColor string */
251 char MediaType
[64]; /* MediaType string */
252 char OutputType
[64]; /* OutputType string */
254 /**** Standard Page Device Dictionary Integer Values ****/
255 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
256 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (see above) */
257 cups_bool_t Collate
; /* Collated copies value */
258 cups_cut_t CutMedia
; /* CutMedia value (see above) */
259 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
260 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
261 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points) */
262 cups_bool_t InsertSheet
; /* InsertSheet value */
263 cups_jog_t Jog
; /* Jog value (see above) */
264 cups_edge_t LeadingEdge
; /* LeadingEdge value (see above) */
265 unsigned Margins
[2]; /* Lower-lefthand margins in points */
266 cups_bool_t ManualFeed
; /* ManualFeed value */
267 unsigned MediaPosition
; /* MediaPosition value */
268 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
269 cups_bool_t MirrorPrint
; /* MirrorPrint value */
270 cups_bool_t NegativePrint
; /* NegativePrint value */
271 unsigned NumCopies
; /* Number of copies to produce */
272 cups_orient_t Orientation
; /* Orientation value (see above) */
273 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
274 unsigned PageSize
[2]; /* Width and length of page in points */
275 cups_bool_t Separations
; /* Separations value */
276 cups_bool_t TraySwitch
; /* TraySwitch value */
277 cups_bool_t Tumble
; /* Tumble value */
279 /**** CUPS Page Device Dictionary Values ****/
280 unsigned cupsWidth
; /* Width of page image in pixels */
281 unsigned cupsHeight
; /* Height of page image in pixels */
282 unsigned cupsMediaType
; /* Media type code */
283 unsigned cupsBitsPerColor
; /* Number of bits for each color */
284 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
285 unsigned cupsBytesPerLine
; /* Number of bytes per line */
286 cups_order_t cupsColorOrder
; /* Order of colors */
287 cups_cspace_t cupsColorSpace
; /* True colorspace */
288 unsigned cupsCompression
; /* Device compression to use */
289 unsigned cupsRowCount
; /* Rows per band */
290 unsigned cupsRowFeed
; /* Feed between bands */
291 unsigned cupsRowStep
; /* Spacing between lines */
293 /**** Version 2 Dictionary Values ****/
294 unsigned cupsNumColors
; /* Number of colors @since CUPS 1.2@ */
295 float cupsBorderlessScalingFactor
;
296 /* Scaling that was applied to page data @since CUPS 1.2@ */
297 float cupsPageSize
[2]; /* Floating point PageSize (scaling *
298 * factor not applied) @since CUPS 1.2@ */
299 float cupsImagingBBox
[4]; /* Floating point ImagingBoundingBox *
300 * (scaling factor not applied) @since CUPS 1.2@ */
301 unsigned cupsInteger
[16]; /* User-defined integer values @since CUPS 1.2@ */
302 float cupsReal
[16]; /* User-defined floating-point values @since CUPS 1.2@ */
303 char cupsString
[16][64]; /* User-defined string values @since CUPS 1.2@ */
304 char cupsMarkerType
[64]; /* Ink/toner type @since CUPS 1.2@ */
305 char cupsRenderingIntent
[64];/* Color rendering intent @since CUPS 1.2@ */
306 char cupsPageSizeName
[64]; /* PageSize name @since CUPS 1.2@ */
307 } cups_page_header2_t
;
309 typedef struct _cups_raster_s cups_raster_t
;
310 /**** Raster stream data ****/
312 typedef int (*cups_interpret_cb_t
)(cups_page_header2_t
*header
, int preferred_bits
);
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
);
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
);
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
);
336 extern unsigned cupsRasterReadHeader2(cups_raster_t
*r
,
337 cups_page_header2_t
*h
);
338 extern unsigned cupsRasterWriteHeader2(cups_raster_t
*r
,
339 cups_page_header2_t
*h
);
343 # endif /* __cplusplus */
345 #endif /* !_CUPS_RASTER_H_ */
348 * End of "$Id: raster.h 5671 2006-06-16 11:17:39Z mike $".