]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/raster.h
Merge CUPS 1.4svn-r7319.
[thirdparty/cups.git] / cups / raster.h
CommitLineData
ef416fc2 1/*
ac884b6a 2 * "$Id$"
ef416fc2 3 *
4 * Raster file definitions for the Common UNIX Printing System (CUPS).
5 *
bc44d920 6 * Copyright 2007 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
923edb68 27# include <cups/cups.h>
ef416fc2 28
29# ifdef __cplusplus
30extern "C" {
31# endif /* __cplusplus */
32
33/*
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...
41 */
42
43/*
44 * Constants...
45 */
46
ed486911 47# define CUPS_RASTER_SYNC 0x52615333 /* RaS3 */
48# define CUPS_RASTER_REVSYNC 0x33536152 /* 3SaR */
ef416fc2 49
50# define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
51# define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
52
ed486911 53# define CUPS_RASTER_SYNCv2 0x52615332 /* RaS2 */
54# define CUPS_RASTER_REVSYNCv2 0x32536152 /* 2SaR */
55
ef416fc2 56
57/*
58 * The following definition can be used to determine if the
59 * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
60 * defined...
61 */
62
63# define CUPS_RASTER_HAVE_COLORIMETRIC 1
64
65
66/*
67 * Types...
68 */
69
ef416fc2 70typedef enum cups_adv_e /**** AdvanceMedia attribute values ****/
71{
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 */
77} cups_adv_t;
78
b86bc4cf 79typedef enum cups_bool_e /**** Boolean type ****/
ef416fc2 80{
b86bc4cf 81 CUPS_FALSE = 0, /* Logical false */
82 CUPS_TRUE = 1 /* Logical true */
83} cups_bool_t;
ef416fc2 84
85typedef enum cups_cspace_e /**** cupsColorSpace attribute values ****/
86{
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 */
103
104 CUPS_CSPACE_CIEXYZ = 15, /* CIE XYZ @since CUPS 1.1.19@ */
105 CUPS_CSPACE_CIELab = 16, /* CIE Lab @since CUPS 1.1.19@ */
106 CUPS_CSPACE_RGBW = 17, /* Red, green, blue, white @since CUPS 1.2@ */
107
108 CUPS_CSPACE_ICC1 = 32, /* ICC-based, 1 color @since CUPS 1.1.19@ */
109 CUPS_CSPACE_ICC2 = 33, /* ICC-based, 2 colors @since CUPS 1.1.19@ */
110 CUPS_CSPACE_ICC3 = 34, /* ICC-based, 3 colors @since CUPS 1.1.19@ */
111 CUPS_CSPACE_ICC4 = 35, /* ICC-based, 4 colors @since CUPS 1.1.19@ */
112 CUPS_CSPACE_ICC5 = 36, /* ICC-based, 5 colors @since CUPS 1.1.19@ */
113 CUPS_CSPACE_ICC6 = 37, /* ICC-based, 6 colors @since CUPS 1.1.19@ */
114 CUPS_CSPACE_ICC7 = 38, /* ICC-based, 7 colors @since CUPS 1.1.19@ */
115 CUPS_CSPACE_ICC8 = 39, /* ICC-based, 8 colors @since CUPS 1.1.19@ */
116 CUPS_CSPACE_ICC9 = 40, /* ICC-based, 9 colors @since CUPS 1.1.19@ */
117 CUPS_CSPACE_ICCA = 41, /* ICC-based, 10 colors @since CUPS 1.1.19@ */
118 CUPS_CSPACE_ICCB = 42, /* ICC-based, 11 colors @since CUPS 1.1.19@ */
119 CUPS_CSPACE_ICCC = 43, /* ICC-based, 12 colors @since CUPS 1.1.19@ */
120 CUPS_CSPACE_ICCD = 44, /* ICC-based, 13 colors @since CUPS 1.1.19@ */
121 CUPS_CSPACE_ICCE = 45, /* ICC-based, 14 colors @since CUPS 1.1.19@ */
122 CUPS_CSPACE_ICCF = 46 /* ICC-based, 15 colors @since CUPS 1.1.19@ */
123} cups_cspace_t;
124
b86bc4cf 125typedef enum cups_cut_e /**** CutMedia attribute values ****/
126{
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 */
132} cups_cut_t;
133
134typedef enum cups_edge_e /**** LeadingEdge attribute values ****/
135{
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 */
140} cups_edge_t;
141
142typedef enum cups_jog_e /**** Jog attribute values ****/
143{
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 */
148} cups_jog_t;
149
5a738aea 150enum cups_mode_e /**** cupsRasterOpen modes ****/
b86bc4cf 151{
152 CUPS_RASTER_READ = 0, /* Open stream for reading */
f7deaa1a 153 CUPS_RASTER_WRITE = 1, /* Open stream for writing */
154 CUPS_RASTER_WRITE_COMPRESSED = 2 /* Open stream for compressed writing @since CUPS 1.3@ */
5a738aea
MS
155};
156
157typedef enum cups_mode_e cups_mode_t; /**** cupsRasterOpen modes ****/
b86bc4cf 158
159typedef enum cups_order_e /**** cupsColorOrder attribute values ****/
160{
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 ... */
164} cups_order_t;
165
166typedef enum cups_orient_e /**** Orientation attribute values ****/
167{
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 */
172} cups_orient_t;
173
ef416fc2 174
175/*
176 * The page header structure contains the standard PostScript page device
177 * dictionary, along with some CUPS-specific parameters that are provided
178 * by the RIPs...
179 *
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.
182 */
183
5a738aea 184typedef struct cups_page_header_s /**** Version 1 page header ****/
ef416fc2 185{
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 */
191
192 /**** Standard Page Device Dictionary Integer Values ****/
193 unsigned AdvanceDistance; /* AdvanceDistance value in points */
194 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
195 cups_bool_t Collate; /* Collated copies value */
196 cups_cut_t CutMedia; /* CutMedia value (see above) */
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) */
200 cups_bool_t InsertSheet; /* InsertSheet value */
201 cups_jog_t Jog; /* Jog value (see above) */
202 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
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 (see above) */
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 */
216
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;
231
232/**** New in CUPS 1.2 ****/
5a738aea 233typedef struct cups_page_header2_s /**** Version 2 page header @since CUPS 1.2@ ****/
ef416fc2 234{
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 */
240
241 /**** Standard Page Device Dictionary Integer Values ****/
242 unsigned AdvanceDistance; /* AdvanceDistance value in points */
243 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
244 cups_bool_t Collate; /* Collated copies value */
245 cups_cut_t CutMedia; /* CutMedia value (see above) */
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) */
249 cups_bool_t InsertSheet; /* InsertSheet value */
250 cups_jog_t Jog; /* Jog value (see above) */
251 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
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 (see above) */
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 */
265
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 */
279
280 /**** Version 2 Dictionary Values ****/
fa73b229 281 unsigned cupsNumColors; /* Number of colors @since CUPS 1.2@ */
923edb68 282 float cupsBorderlessScalingFactor;
b423cd4c 283 /* Scaling that was applied to page data @since CUPS 1.2@ */
923edb68 284 float cupsPageSize[2]; /* Floating point PageSize (scaling *
285 * factor not applied) @since CUPS 1.2@ */
286 float cupsImagingBBox[4]; /* Floating point ImagingBoundingBox *
287 * (scaling factor not applied) @since CUPS 1.2@ */
fa73b229 288 unsigned cupsInteger[16]; /* User-defined integer values @since CUPS 1.2@ */
289 float cupsReal[16]; /* User-defined floating-point values @since CUPS 1.2@ */
290 char cupsString[16][64]; /* User-defined string values @since CUPS 1.2@ */
291 char cupsMarkerType[64]; /* Ink/toner type @since CUPS 1.2@ */
292 char cupsRenderingIntent[64];/* Color rendering intent @since CUPS 1.2@ */
293 char cupsPageSizeName[64]; /* PageSize name @since CUPS 1.2@ */
ef416fc2 294} cups_page_header2_t;
295
f301802f 296typedef struct _cups_raster_s cups_raster_t;
297 /**** Raster stream data ****/
ef416fc2 298
a74454a7 299typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
5a738aea
MS
300 /**** cupsRasterInterpretPPD callback function
301 *
302 * This function is called by
303 * @link cupsRasterInterpretPPD@ to
304 * validate (and update, as needed)
305 * the page header attributes.
306 ****/
a74454a7 307
ef416fc2 308
309/*
310 * Prototypes...
311 */
312
313extern void cupsRasterClose(cups_raster_t *r);
314extern cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode);
315extern unsigned cupsRasterReadHeader(cups_raster_t *r,
316 cups_page_header_t *h);
317extern unsigned cupsRasterReadPixels(cups_raster_t *r,
318 unsigned char *p, unsigned len);
319extern unsigned cupsRasterWriteHeader(cups_raster_t *r,
320 cups_page_header_t *h);
321extern unsigned cupsRasterWritePixels(cups_raster_t *r,
322 unsigned char *p, unsigned len);
323
324/**** New in CUPS 1.2 ****/
325extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
923edb68 326 ppd_file_t *ppd,
327 int num_options,
a74454a7 328 cups_option_t *options,
2fb76298 329 cups_interpret_cb_t func) _CUPS_API_1_2;
ef416fc2 330extern unsigned cupsRasterReadHeader2(cups_raster_t *r,
2fb76298 331 cups_page_header2_t *h) _CUPS_API_1_2;
ef416fc2 332extern unsigned cupsRasterWriteHeader2(cups_raster_t *r,
2fb76298 333 cups_page_header2_t *h) _CUPS_API_1_2;
ef416fc2 334
f7deaa1a 335/**** New in CUPS 1.3 ****/
2fb76298 336extern const char *cupsRasterErrorString(void) _CUPS_API_1_3;
f7deaa1a 337
ef416fc2 338# ifdef __cplusplus
339}
340# endif /* __cplusplus */
341
342#endif /* !_CUPS_RASTER_H_ */
343
344/*
ac884b6a 345 * End of "$Id$".
ef416fc2 346 */