2 * "$Id: raster.h 181 2006-06-22 20:01:18Z jlovell $"
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 */
90 CUPS_RASTER_WRITE_COMPRESSED
= 2 /* Open stream for compressed writing @since CUPS 1.3@ */
93 typedef enum cups_bool_e
/**** Boolean type ****/
95 CUPS_FALSE
= 0, /* Logical false */
96 CUPS_TRUE
= 1 /* Logical true */
99 typedef enum cups_jog_e
/**** Jog attribute values ****/
101 CUPS_JOG_NONE
= 0, /* Never move pages */
102 CUPS_JOG_FILE
= 1, /* Move pages after this file */
103 CUPS_JOG_JOB
= 2, /* Move pages after this job */
104 CUPS_JOG_SET
= 3 /* Move pages after this set */
107 typedef enum cups_orient_e
/**** Orientation attribute values ****/
109 CUPS_ORIENT_0
= 0, /* Don't rotate the page */
110 CUPS_ORIENT_90
= 1, /* Rotate the page counter-clockwise */
111 CUPS_ORIENT_180
= 2, /* Turn the page upside down */
112 CUPS_ORIENT_270
= 3 /* Rotate the page clockwise */
115 typedef enum cups_cut_e
/**** CutMedia attribute values ****/
117 CUPS_CUT_NONE
= 0, /* Never cut the roll */
118 CUPS_CUT_FILE
= 1, /* Cut the roll after this file */
119 CUPS_CUT_JOB
= 2, /* Cut the roll after this job */
120 CUPS_CUT_SET
= 3, /* Cut the roll after this set */
121 CUPS_CUT_PAGE
= 4 /* Cut the roll after this page */
124 typedef enum cups_adv_e
/**** AdvanceMedia attribute values ****/
126 CUPS_ADVANCE_NONE
= 0, /* Never advance the roll */
127 CUPS_ADVANCE_FILE
= 1, /* Advance the roll after this file */
128 CUPS_ADVANCE_JOB
= 2, /* Advance the roll after this job */
129 CUPS_ADVANCE_SET
= 3, /* Advance the roll after this set */
130 CUPS_ADVANCE_PAGE
= 4 /* Advance the roll after this page */
133 typedef enum cups_edge_e
/**** LeadingEdge attribute values ****/
135 CUPS_EDGE_TOP
= 0, /* Leading edge is the top of the page */
136 CUPS_EDGE_RIGHT
= 1, /* Leading edge is the right of the page */
137 CUPS_EDGE_BOTTOM
= 2, /* Leading edge is the bottom of the page */
138 CUPS_EDGE_LEFT
= 3 /* Leading edge is the left of the page */
141 typedef enum cups_order_e
/**** cupsColorOrder attribute values ****/
143 CUPS_ORDER_CHUNKED
= 0, /* CMYK CMYK CMYK ... */
144 CUPS_ORDER_BANDED
= 1, /* CCC MMM YYY KKK ... */
145 CUPS_ORDER_PLANAR
= 2 /* CCC ... MMM ... YYY ... KKK ... */
148 typedef enum cups_cspace_e
/**** cupsColorSpace attribute values ****/
150 CUPS_CSPACE_W
= 0, /* Luminance */
151 CUPS_CSPACE_RGB
= 1, /* Red, green, blue */
152 CUPS_CSPACE_RGBA
= 2, /* Red, green, blue, alpha */
153 CUPS_CSPACE_K
= 3, /* Black */
154 CUPS_CSPACE_CMY
= 4, /* Cyan, magenta, yellow */
155 CUPS_CSPACE_YMC
= 5, /* Yellow, magenta, cyan */
156 CUPS_CSPACE_CMYK
= 6, /* Cyan, magenta, yellow, black */
157 CUPS_CSPACE_YMCK
= 7, /* Yellow, magenta, cyan, black */
158 CUPS_CSPACE_KCMY
= 8, /* Black, cyan, magenta, yellow */
159 CUPS_CSPACE_KCMYcm
= 9, /* Black, cyan, magenta, yellow, *
160 * light-cyan, light-magenta */
161 CUPS_CSPACE_GMCK
= 10, /* Gold, magenta, yellow, black */
162 CUPS_CSPACE_GMCS
= 11, /* Gold, magenta, yellow, silver */
163 CUPS_CSPACE_WHITE
= 12, /* White ink (as black) */
164 CUPS_CSPACE_GOLD
= 13, /* Gold foil */
165 CUPS_CSPACE_SILVER
= 14, /* Silver foil */
167 CUPS_CSPACE_CIEXYZ
= 15, /* CIE XYZ @since CUPS 1.1.19@ */
168 CUPS_CSPACE_CIELab
= 16, /* CIE Lab @since CUPS 1.1.19@ */
169 CUPS_CSPACE_RGBW
= 17, /* Red, green, blue, white @since CUPS 1.2@ */
171 CUPS_CSPACE_ICC1
= 32, /* ICC-based, 1 color @since CUPS 1.1.19@ */
172 CUPS_CSPACE_ICC2
= 33, /* ICC-based, 2 colors @since CUPS 1.1.19@ */
173 CUPS_CSPACE_ICC3
= 34, /* ICC-based, 3 colors @since CUPS 1.1.19@ */
174 CUPS_CSPACE_ICC4
= 35, /* ICC-based, 4 colors @since CUPS 1.1.19@ */
175 CUPS_CSPACE_ICC5
= 36, /* ICC-based, 5 colors @since CUPS 1.1.19@ */
176 CUPS_CSPACE_ICC6
= 37, /* ICC-based, 6 colors @since CUPS 1.1.19@ */
177 CUPS_CSPACE_ICC7
= 38, /* ICC-based, 7 colors @since CUPS 1.1.19@ */
178 CUPS_CSPACE_ICC8
= 39, /* ICC-based, 8 colors @since CUPS 1.1.19@ */
179 CUPS_CSPACE_ICC9
= 40, /* ICC-based, 9 colors @since CUPS 1.1.19@ */
180 CUPS_CSPACE_ICCA
= 41, /* ICC-based, 10 colors @since CUPS 1.1.19@ */
181 CUPS_CSPACE_ICCB
= 42, /* ICC-based, 11 colors @since CUPS 1.1.19@ */
182 CUPS_CSPACE_ICCC
= 43, /* ICC-based, 12 colors @since CUPS 1.1.19@ */
183 CUPS_CSPACE_ICCD
= 44, /* ICC-based, 13 colors @since CUPS 1.1.19@ */
184 CUPS_CSPACE_ICCE
= 45, /* ICC-based, 14 colors @since CUPS 1.1.19@ */
185 CUPS_CSPACE_ICCF
= 46 /* ICC-based, 15 colors @since CUPS 1.1.19@ */
190 * The page header structure contains the standard PostScript page device
191 * dictionary, along with some CUPS-specific parameters that are provided
194 * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
195 * (from CUPS 1.2 and higher) page header, for binary compatibility.
198 typedef struct cups_page_header_s
/**** Version 1 Page Header ****/
200 /**** Standard Page Device Dictionary String Values ****/
201 char MediaClass
[64]; /* MediaClass string */
202 char MediaColor
[64]; /* MediaColor string */
203 char MediaType
[64]; /* MediaType string */
204 char OutputType
[64]; /* OutputType string */
206 /**** Standard Page Device Dictionary Integer Values ****/
207 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
208 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (see above) */
209 cups_bool_t Collate
; /* Collated copies value */
210 cups_cut_t CutMedia
; /* CutMedia value (see above) */
211 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
212 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
213 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points) */
214 cups_bool_t InsertSheet
; /* InsertSheet value */
215 cups_jog_t Jog
; /* Jog value (see above) */
216 cups_edge_t LeadingEdge
; /* LeadingEdge value (see above) */
217 unsigned Margins
[2]; /* Lower-lefthand margins in points */
218 cups_bool_t ManualFeed
; /* ManualFeed value */
219 unsigned MediaPosition
; /* MediaPosition value */
220 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
221 cups_bool_t MirrorPrint
; /* MirrorPrint value */
222 cups_bool_t NegativePrint
; /* NegativePrint value */
223 unsigned NumCopies
; /* Number of copies to produce */
224 cups_orient_t Orientation
; /* Orientation value (see above) */
225 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
226 unsigned PageSize
[2]; /* Width and length of page in points */
227 cups_bool_t Separations
; /* Separations value */
228 cups_bool_t TraySwitch
; /* TraySwitch value */
229 cups_bool_t Tumble
; /* Tumble value */
231 /**** CUPS Page Device Dictionary Values ****/
232 unsigned cupsWidth
; /* Width of page image in pixels */
233 unsigned cupsHeight
; /* Height of page image in pixels */
234 unsigned cupsMediaType
; /* Media type code */
235 unsigned cupsBitsPerColor
; /* Number of bits for each color */
236 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
237 unsigned cupsBytesPerLine
; /* Number of bytes per line */
238 cups_order_t cupsColorOrder
; /* Order of colors */
239 cups_cspace_t cupsColorSpace
; /* True colorspace */
240 unsigned cupsCompression
; /* Device compression to use */
241 unsigned cupsRowCount
; /* Rows per band */
242 unsigned cupsRowFeed
; /* Feed between bands */
243 unsigned cupsRowStep
; /* Spacing between lines */
244 } cups_page_header_t
;
246 /**** New in CUPS 1.2 ****/
247 typedef struct cups_page_header2_s
/**** Version 2 Page Header @since CUPS 1.2@ ****/
249 /**** Standard Page Device Dictionary String Values ****/
250 char MediaClass
[64]; /* MediaClass string */
251 char MediaColor
[64]; /* MediaColor string */
252 char MediaType
[64]; /* MediaType string */
253 char OutputType
[64]; /* OutputType string */
255 /**** Standard Page Device Dictionary Integer Values ****/
256 unsigned AdvanceDistance
; /* AdvanceDistance value in points */
257 cups_adv_t AdvanceMedia
; /* AdvanceMedia value (see above) */
258 cups_bool_t Collate
; /* Collated copies value */
259 cups_cut_t CutMedia
; /* CutMedia value (see above) */
260 cups_bool_t Duplex
; /* Duplexed (double-sided) value */
261 unsigned HWResolution
[2]; /* Resolution in dots-per-inch */
262 unsigned ImagingBoundingBox
[4]; /* Pixel region that is painted (points) */
263 cups_bool_t InsertSheet
; /* InsertSheet value */
264 cups_jog_t Jog
; /* Jog value (see above) */
265 cups_edge_t LeadingEdge
; /* LeadingEdge value (see above) */
266 unsigned Margins
[2]; /* Lower-lefthand margins in points */
267 cups_bool_t ManualFeed
; /* ManualFeed value */
268 unsigned MediaPosition
; /* MediaPosition value */
269 unsigned MediaWeight
; /* MediaWeight value in grams/m^2 */
270 cups_bool_t MirrorPrint
; /* MirrorPrint value */
271 cups_bool_t NegativePrint
; /* NegativePrint value */
272 unsigned NumCopies
; /* Number of copies to produce */
273 cups_orient_t Orientation
; /* Orientation value (see above) */
274 cups_bool_t OutputFaceUp
; /* OutputFaceUp value */
275 unsigned PageSize
[2]; /* Width and length of page in points */
276 cups_bool_t Separations
; /* Separations value */
277 cups_bool_t TraySwitch
; /* TraySwitch value */
278 cups_bool_t Tumble
; /* Tumble value */
280 /**** CUPS Page Device Dictionary Values ****/
281 unsigned cupsWidth
; /* Width of page image in pixels */
282 unsigned cupsHeight
; /* Height of page image in pixels */
283 unsigned cupsMediaType
; /* Media type code */
284 unsigned cupsBitsPerColor
; /* Number of bits for each color */
285 unsigned cupsBitsPerPixel
; /* Number of bits for each pixel */
286 unsigned cupsBytesPerLine
; /* Number of bytes per line */
287 cups_order_t cupsColorOrder
; /* Order of colors */
288 cups_cspace_t cupsColorSpace
; /* True colorspace */
289 unsigned cupsCompression
; /* Device compression to use */
290 unsigned cupsRowCount
; /* Rows per band */
291 unsigned cupsRowFeed
; /* Feed between bands */
292 unsigned cupsRowStep
; /* Spacing between lines */
294 /**** Version 2 Dictionary Values ****/
295 unsigned cupsNumColors
; /* Number of colors @since CUPS 1.2@ */
296 float cupsBorderlessScalingFactor
;
297 /* Scaling that was applied to page data @since CUPS 1.2@ */
298 float cupsPageSize
[2]; /* Floating point PageSize (scaling *
299 * factor not applied) @since CUPS 1.2@ */
300 float cupsImagingBBox
[4]; /* Floating point ImagingBoundingBox *
301 * (scaling factor not applied) @since CUPS 1.2@ */
302 unsigned cupsInteger
[16]; /* User-defined integer values @since CUPS 1.2@ */
303 float cupsReal
[16]; /* User-defined floating-point values @since CUPS 1.2@ */
304 char cupsString
[16][64]; /* User-defined string values @since CUPS 1.2@ */
305 char cupsMarkerType
[64]; /* Ink/toner type @since CUPS 1.2@ */
306 char cupsRenderingIntent
[64];/* Color rendering intent @since CUPS 1.2@ */
307 char cupsPageSizeName
[64]; /* PageSize name @since CUPS 1.2@ */
308 } cups_page_header2_t
;
310 typedef struct _cups_raster_s cups_raster_t
;
311 /**** Raster stream data ****/
313 typedef int (*cups_interpret_cb_t
)(cups_page_header2_t
*header
, int preferred_bits
);
320 extern void cupsRasterClose(cups_raster_t
*r
);
321 extern cups_raster_t
*cupsRasterOpen(int fd
, cups_mode_t mode
);
322 extern unsigned cupsRasterReadHeader(cups_raster_t
*r
,
323 cups_page_header_t
*h
);
324 extern unsigned cupsRasterReadPixels(cups_raster_t
*r
,
325 unsigned char *p
, unsigned len
);
326 extern unsigned cupsRasterWriteHeader(cups_raster_t
*r
,
327 cups_page_header_t
*h
);
328 extern unsigned cupsRasterWritePixels(cups_raster_t
*r
,
329 unsigned char *p
, unsigned len
);
331 /**** New in CUPS 1.2 ****/
332 extern int cupsRasterInterpretPPD(cups_page_header2_t
*h
,
335 cups_option_t
*options
,
336 cups_interpret_cb_t func
);
337 extern unsigned cupsRasterReadHeader2(cups_raster_t
*r
,
338 cups_page_header2_t
*h
);
339 extern unsigned cupsRasterWriteHeader2(cups_raster_t
*r
,
340 cups_page_header2_t
*h
);
344 # endif /* __cplusplus */
346 #endif /* !_CUPS_RASTER_H_ */
349 * End of "$Id: raster.h 181 2006-06-22 20:01:18Z jlovell $".