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