]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/raster.h
Add floating point PageSize and ImagingBBox values along with page
[thirdparty/cups.git] / filter / raster.h
CommitLineData
cfb0ab24 1/*
b2e10895 2 * "$Id$"
cfb0ab24 3 *
4 * Raster file definitions for the Common UNIX Printing System (CUPS).
5 *
24c1b5ce 6 * Copyright 1997-2006 by Easy Software Products.
cfb0ab24 7 *
c08f63d5 8 * This file is part of the CUPS Imaging library.
9 *
cfb0ab24 10 * These coded instructions, statements, and computer programs are the
11 * property of Easy Software Products and are protected by Federal
c08f63d5 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
15 * at:
cfb0ab24 16 *
17 * Attn: CUPS Licensing Information
18 * Easy Software Products
8cb60b06 19 * 44141 Airport View Drive, Suite 204
c08f63d5 20 * Hollywood, Maryland 20636 USA
cfb0ab24 21 *
9639c4de 22 * Voice: (301) 373-9600
cfb0ab24 23 * EMail: cups-info@cups.org
24 * WWW: http://www.cups.org
b87e43e9 25 *
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
b2e10895 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
b87e43e9 30 * GhostScript (or its derivatives) is governed by the CUPS license
31 * agreement.
dab1a4d8 32 *
33 * This file is subject to the Apple OS-Developed Software exception.
cfb0ab24 34 */
35
36#ifndef _CUPS_RASTER_H_
37# define _CUPS_RASTER_H_
38
1594457e 39/*
40 * Include necessary headers...
41 */
42
3fa9815c 43# include <cups/ppd.h>
1594457e 44
cb985dd0 45# ifdef __cplusplus
46extern "C" {
47# endif /* __cplusplus */
48
cfb0ab24 49/*
1594457e 50 * Every non-PostScript printer driver that supports raster images
51 * should use the application/vnd.cups-raster image file format.
b2e10895 52 * Since both the PostScript RIP (pstoraster, based on GNU/GPL
1594457e 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...
cfb0ab24 57 */
58
59/*
60 * Constants...
61 */
62
1594457e 63# define CUPS_RASTER_SYNC 0x52615332 /* RaS2 */
64# define CUPS_RASTER_REVSYNC 0x32536152 /* 2SaR */
65
66# define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
67# define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
cfb0ab24 68
69
bd32ee44 70/*
71 * The following definition can be used to determine if the
72 * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
73 * defined...
74 */
75
76# define CUPS_RASTER_HAVE_COLORIMETRIC 1
77
78
cfb0ab24 79/*
80 * Types...
81 */
82
5ae68d3c 83typedef enum cups_mode_e /**** Raster modes ****/
cfb0ab24 84{
5ae68d3c 85 CUPS_RASTER_READ = 0, /* Open stream for reading */
86 CUPS_RASTER_WRITE = 1 /* Open stream for writing */
58ec2a95 87} cups_mode_t;
88
5ae68d3c 89typedef enum cups_bool_e /**** Boolean type ****/
58ec2a95 90{
5ae68d3c 91 CUPS_FALSE = 0, /* Logical false */
92 CUPS_TRUE = 1 /* Logical true */
cfb0ab24 93} cups_bool_t;
94
5ae68d3c 95typedef enum cups_jog_e /**** Jog attribute values ****/
cfb0ab24 96{
5ae68d3c 97 CUPS_JOG_NONE = 0, /* Never move pages */
98 CUPS_JOG_FILE = 1, /* Move pages after this file */
99 CUPS_JOG_JOB = 2, /* Move pages after this job */
100 CUPS_JOG_SET = 3 /* Move pages after this set */
cfb0ab24 101} cups_jog_t;
102
5ae68d3c 103typedef enum cups_orient_e /**** Orientation attribute values ****/
cfb0ab24 104{
5ae68d3c 105 CUPS_ORIENT_0 = 0, /* Don't rotate the page */
106 CUPS_ORIENT_90 = 1, /* Rotate the page counter-clockwise */
107 CUPS_ORIENT_180 = 2, /* Turn the page upside down */
108 CUPS_ORIENT_270 = 3 /* Rotate the page clockwise */
cfb0ab24 109} cups_orient_t;
110
5ae68d3c 111typedef enum cups_cut_e /**** CutMedia attribute values ****/
cfb0ab24 112{
5ae68d3c 113 CUPS_CUT_NONE = 0, /* Never cut the roll */
114 CUPS_CUT_FILE = 1, /* Cut the roll after this file */
115 CUPS_CUT_JOB = 2, /* Cut the roll after this job */
116 CUPS_CUT_SET = 3, /* Cut the roll after this set */
117 CUPS_CUT_PAGE = 4 /* Cut the roll after this page */
cfb0ab24 118} cups_cut_t;
119
5ae68d3c 120typedef enum cups_adv_e /**** AdvanceMedia attribute values ****/
cfb0ab24 121{
5ae68d3c 122 CUPS_ADVANCE_NONE = 0, /* Never advance the roll */
123 CUPS_ADVANCE_FILE = 1, /* Advance the roll after this file */
124 CUPS_ADVANCE_JOB = 2, /* Advance the roll after this job */
125 CUPS_ADVANCE_SET = 3, /* Advance the roll after this set */
126 CUPS_ADVANCE_PAGE = 4 /* Advance the roll after this page */
cfb0ab24 127} cups_adv_t;
128
5ae68d3c 129typedef enum cups_edge_e /**** LeadingEdge attribute values ****/
cfb0ab24 130{
5ae68d3c 131 CUPS_EDGE_TOP = 0, /* Leading edge is the top of the page */
132 CUPS_EDGE_RIGHT = 1, /* Leading edge is the right of the page */
133 CUPS_EDGE_BOTTOM = 2, /* Leading edge is the bottom of the page */
134 CUPS_EDGE_LEFT = 3 /* Leading edge is the left of the page */
58ec2a95 135} cups_edge_t;
136
5ae68d3c 137typedef enum cups_order_e /**** cupsColorOrder attribute values ****/
58ec2a95 138{
5ae68d3c 139 CUPS_ORDER_CHUNKED = 0, /* CMYK CMYK CMYK ... */
140 CUPS_ORDER_BANDED = 1, /* CCC MMM YYY KKK ... */
141 CUPS_ORDER_PLANAR = 2 /* CCC ... MMM ... YYY ... KKK ... */
58ec2a95 142} cups_order_t;
143
5ae68d3c 144typedef enum cups_cspace_e /**** cupsColorSpace attribute values ****/
58ec2a95 145{
5ae68d3c 146 CUPS_CSPACE_W = 0, /* Luminance */
147 CUPS_CSPACE_RGB = 1, /* Red, green, blue */
148 CUPS_CSPACE_RGBA = 2, /* Red, green, blue, alpha */
149 CUPS_CSPACE_K = 3, /* Black */
150 CUPS_CSPACE_CMY = 4, /* Cyan, magenta, yellow */
151 CUPS_CSPACE_YMC = 5, /* Yellow, magenta, cyan */
152 CUPS_CSPACE_CMYK = 6, /* Cyan, magenta, yellow, black */
153 CUPS_CSPACE_YMCK = 7, /* Yellow, magenta, cyan, black */
154 CUPS_CSPACE_KCMY = 8, /* Black, cyan, magenta, yellow */
155 CUPS_CSPACE_KCMYcm = 9, /* Black, cyan, magenta, yellow, *
58ec2a95 156 * light-cyan, light-magenta */
5ae68d3c 157 CUPS_CSPACE_GMCK = 10, /* Gold, magenta, yellow, black */
158 CUPS_CSPACE_GMCS = 11, /* Gold, magenta, yellow, silver */
159 CUPS_CSPACE_WHITE = 12, /* White ink (as black) */
160 CUPS_CSPACE_GOLD = 13, /* Gold foil */
161 CUPS_CSPACE_SILVER = 14, /* Silver foil */
1594457e 162
4873971b 163 CUPS_CSPACE_CIEXYZ = 15, /* CIE XYZ @since CUPS 1.1.19@ */
164 CUPS_CSPACE_CIELab = 16, /* CIE Lab @since CUPS 1.1.19@ */
165 CUPS_CSPACE_RGBW = 17, /* Red, green, blue, white @since CUPS 1.2@ */
166
167 CUPS_CSPACE_ICC1 = 32, /* ICC-based, 1 color @since CUPS 1.1.19@ */
168 CUPS_CSPACE_ICC2 = 33, /* ICC-based, 2 colors @since CUPS 1.1.19@ */
169 CUPS_CSPACE_ICC3 = 34, /* ICC-based, 3 colors @since CUPS 1.1.19@ */
170 CUPS_CSPACE_ICC4 = 35, /* ICC-based, 4 colors @since CUPS 1.1.19@ */
171 CUPS_CSPACE_ICC5 = 36, /* ICC-based, 5 colors @since CUPS 1.1.19@ */
172 CUPS_CSPACE_ICC6 = 37, /* ICC-based, 6 colors @since CUPS 1.1.19@ */
173 CUPS_CSPACE_ICC7 = 38, /* ICC-based, 7 colors @since CUPS 1.1.19@ */
174 CUPS_CSPACE_ICC8 = 39, /* ICC-based, 8 colors @since CUPS 1.1.19@ */
175 CUPS_CSPACE_ICC9 = 40, /* ICC-based, 9 colors @since CUPS 1.1.19@ */
176 CUPS_CSPACE_ICCA = 41, /* ICC-based, 10 colors @since CUPS 1.1.19@ */
177 CUPS_CSPACE_ICCB = 42, /* ICC-based, 11 colors @since CUPS 1.1.19@ */
178 CUPS_CSPACE_ICCC = 43, /* ICC-based, 12 colors @since CUPS 1.1.19@ */
179 CUPS_CSPACE_ICCD = 44, /* ICC-based, 13 colors @since CUPS 1.1.19@ */
180 CUPS_CSPACE_ICCE = 45, /* ICC-based, 14 colors @since CUPS 1.1.19@ */
181 CUPS_CSPACE_ICCF = 46 /* ICC-based, 15 colors @since CUPS 1.1.19@ */
58ec2a95 182} cups_cspace_t;
cfb0ab24 183
184
185/*
186 * The page header structure contains the standard PostScript page device
187 * dictionary, along with some CUPS-specific parameters that are provided
188 * by the RIPs...
57147a00 189 *
190 * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
191 * (from CUPS 1.2 and higher) page header, for binary compatibility.
cfb0ab24 192 */
193
5ae68d3c 194typedef struct cups_page_header_s /**** Version 1 Page Header ****/
57147a00 195{
196 /**** Standard Page Device Dictionary String Values ****/
197 char MediaClass[64]; /* MediaClass string */
198 char MediaColor[64]; /* MediaColor string */
199 char MediaType[64]; /* MediaType string */
200 char OutputType[64]; /* OutputType string */
201
202 /**** Standard Page Device Dictionary Integer Values ****/
203 unsigned AdvanceDistance; /* AdvanceDistance value in points */
204 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
205 cups_bool_t Collate; /* Collated copies value */
206 cups_cut_t CutMedia; /* CutMedia value (see above) */
207 cups_bool_t Duplex; /* Duplexed (double-sided) value */
208 unsigned HWResolution[2]; /* Resolution in dots-per-inch */
209 unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points) */
210 cups_bool_t InsertSheet; /* InsertSheet value */
211 cups_jog_t Jog; /* Jog value (see above) */
212 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
213 unsigned Margins[2]; /* Lower-lefthand margins in points */
214 cups_bool_t ManualFeed; /* ManualFeed value */
215 unsigned MediaPosition; /* MediaPosition value */
216 unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
217 cups_bool_t MirrorPrint; /* MirrorPrint value */
218 cups_bool_t NegativePrint; /* NegativePrint value */
219 unsigned NumCopies; /* Number of copies to produce */
220 cups_orient_t Orientation; /* Orientation value (see above) */
221 cups_bool_t OutputFaceUp; /* OutputFaceUp value */
222 unsigned PageSize[2]; /* Width and length of page in points */
223 cups_bool_t Separations; /* Separations value */
224 cups_bool_t TraySwitch; /* TraySwitch value */
225 cups_bool_t Tumble; /* Tumble value */
226
227 /**** CUPS Page Device Dictionary Values ****/
228 unsigned cupsWidth; /* Width of page image in pixels */
229 unsigned cupsHeight; /* Height of page image in pixels */
230 unsigned cupsMediaType; /* Media type code */
231 unsigned cupsBitsPerColor; /* Number of bits for each color */
232 unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
233 unsigned cupsBytesPerLine; /* Number of bytes per line */
234 cups_order_t cupsColorOrder; /* Order of colors */
235 cups_cspace_t cupsColorSpace; /* True colorspace */
236 unsigned cupsCompression; /* Device compression to use */
237 unsigned cupsRowCount; /* Rows per band */
238 unsigned cupsRowFeed; /* Feed between bands */
239 unsigned cupsRowStep; /* Spacing between lines */
240} cups_page_header_t;
241
4873971b 242/**** New in CUPS 1.2 ****/
243typedef struct cups_page_header2_s /**** Version 2 Page Header @since CUPS 1.2@ ****/
cfb0ab24 244{
58ec2a95 245 /**** Standard Page Device Dictionary String Values ****/
246 char MediaClass[64]; /* MediaClass string */
247 char MediaColor[64]; /* MediaColor string */
248 char MediaType[64]; /* MediaType string */
249 char OutputType[64]; /* OutputType string */
250
251 /**** Standard Page Device Dictionary Integer Values ****/
8debe872 252 unsigned AdvanceDistance; /* AdvanceDistance value in points */
cfb0ab24 253 cups_adv_t AdvanceMedia; /* AdvanceMedia value (see above) */
254 cups_bool_t Collate; /* Collated copies value */
255 cups_cut_t CutMedia; /* CutMedia value (see above) */
256 cups_bool_t Duplex; /* Duplexed (double-sided) value */
58ec2a95 257 unsigned HWResolution[2]; /* Resolution in dots-per-inch */
8debe872 258 unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points) */
58ec2a95 259 cups_bool_t InsertSheet; /* InsertSheet value */
cfb0ab24 260 cups_jog_t Jog; /* Jog value (see above) */
58ec2a95 261 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
8debe872 262 unsigned Margins[2]; /* Lower-lefthand margins in points */
cfb0ab24 263 cups_bool_t ManualFeed; /* ManualFeed value */
cfb0ab24 264 unsigned MediaPosition; /* MediaPosition value */
cfb0ab24 265 unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
266 cups_bool_t MirrorPrint; /* MirrorPrint value */
267 cups_bool_t NegativePrint; /* NegativePrint value */
268 unsigned NumCopies; /* Number of copies to produce */
269 cups_orient_t Orientation; /* Orientation value (see above) */
270 cups_bool_t OutputFaceUp; /* OutputFaceUp value */
8debe872 271 unsigned PageSize[2]; /* Width and length of page in points */
cfb0ab24 272 cups_bool_t Separations; /* Separations value */
273 cups_bool_t TraySwitch; /* TraySwitch value */
274 cups_bool_t Tumble; /* Tumble value */
cfb0ab24 275
276 /**** CUPS Page Device Dictionary Values ****/
cb985dd0 277 unsigned cupsWidth; /* Width of page image in pixels */
278 unsigned cupsHeight; /* Height of page image in pixels */
991a5d0d 279 unsigned cupsMediaType; /* Media type code */
58ec2a95 280 unsigned cupsBitsPerColor; /* Number of bits for each color */
281 unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
282 unsigned cupsBytesPerLine; /* Number of bytes per line */
283 cups_order_t cupsColorOrder; /* Order of colors */
284 cups_cspace_t cupsColorSpace; /* True colorspace */
991a5d0d 285 unsigned cupsCompression; /* Device compression to use */
554fab97 286 unsigned cupsRowCount; /* Rows per band */
287 unsigned cupsRowFeed; /* Feed between bands */
288 unsigned cupsRowStep; /* Spacing between lines */
1594457e 289
290 /**** Version 2 Dictionary Values ****/
42eff782 291 unsigned cupsNumColors; /* Number of colors @since CUPS 1.2@ */
292 float cupsPageScaling; /* Scaling that was applied to page data */
293 float cupsPageSize[2]; /* Floating point PageSize @since CUPS 1.2@ */
294 float cupsImagingBBox[4]; /* Floating point ImagingBoundingBox @since CUPS 1.2@ */
295 unsigned cupsInteger[16]; /* User-defined integer values @since CUPS 1.2@ */
296 float cupsReal[16]; /* User-defined floating-point values @since CUPS 1.2@ */
297 char cupsString[16][64]; /* User-defined string values @since CUPS 1.2@ */
298 char cupsMarkerType[64]; /* Ink/toner type @since CUPS 1.2@ */
299 char cupsRenderingIntent[64];/* Color rendering intent @since CUPS 1.2@ */
300 char cupsPageSizeName[64]; /* PageSize name @since CUPS 1.2@ */
57147a00 301} cups_page_header2_t;
cfb0ab24 302
4873971b 303typedef struct _cups_raster_s /**** Raster stream data ****/
58ec2a95 304{
1594457e 305 unsigned sync; /* Sync word from start of stream */
2e32fcdb 306 int fd; /* File descriptor */
1594457e 307 cups_mode_t mode; /* Read/write mode */
57147a00 308 cups_page_header2_t header; /* Raster header for current page */
1594457e 309 int count, /* Current row run-length count */
310 remaining, /* Remaining rows in page image */
311 bpp; /* Bytes per pixel/color */
312 unsigned char *pixels, /* Pixels for current row */
313 *pend, /* End of pixel buffer */
314 *pcurrent; /* Current byte in pixel buffer */
58ec2a95 315} cups_raster_t;
316
317
318/*
319 * Prototypes...
320 */
321
322extern void cupsRasterClose(cups_raster_t *r);
2e32fcdb 323extern cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode);
58ec2a95 324extern unsigned cupsRasterReadHeader(cups_raster_t *r,
325 cups_page_header_t *h);
326extern unsigned cupsRasterReadPixels(cups_raster_t *r,
327 unsigned char *p, unsigned len);
328extern unsigned cupsRasterWriteHeader(cups_raster_t *r,
329 cups_page_header_t *h);
330extern unsigned cupsRasterWritePixels(cups_raster_t *r,
331 unsigned char *p, unsigned len);
332
4873971b 333/**** New in CUPS 1.2 ****/
334extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
335 ppd_file_t *ppd);
336extern unsigned cupsRasterReadHeader2(cups_raster_t *r,
337 cups_page_header2_t *h);
338extern unsigned cupsRasterWriteHeader2(cups_raster_t *r,
339 cups_page_header2_t *h);
3fa9815c 340
cb985dd0 341# ifdef __cplusplus
342}
343# endif /* __cplusplus */
344
cfb0ab24 345#endif /* !_CUPS_RASTER_H_ */
346
347/*
b2e10895 348 * End of "$Id$".
cfb0ab24 349 */