]> git.ipfire.org Git - thirdparty/cups.git/blame - filter/raster.h
Load cups into easysw/current.
[thirdparty/cups.git] / filter / raster.h
CommitLineData
ef416fc2 1/*
f301802f 2 * "$Id: raster.h 5516 2006-05-11 23:54:05Z mike $"
ef416fc2 3 *
4 * Raster file definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 by Easy Software Products.
7 *
8 * This file is part of the CUPS Imaging library.
9 *
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
15 * at:
16 *
17 * Attn: CUPS Licensing Information
18 * Easy Software Products
19 * 44141 Airport View Drive, Suite 204
20 * Hollywood, Maryland 20636 USA
21 *
22 * Voice: (301) 373-9600
23 * EMail: cups-info@cups.org
24 * WWW: http://www.cups.org
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
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
31 * agreement.
32 *
33 * This file is subject to the Apple OS-Developed Software exception.
34 */
35
36#ifndef _CUPS_RASTER_H_
37# define _CUPS_RASTER_H_
38
39/*
40 * Include necessary headers...
41 */
42
923edb68 43# include <cups/cups.h>
ef416fc2 44
45# ifdef __cplusplus
46extern "C" {
47# endif /* __cplusplus */
48
49/*
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...
57 */
58
59/*
60 * Constants...
61 */
62
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 */
68
69
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
79/*
80 * Types...
81 */
82
83typedef enum cups_mode_e /**** Raster modes ****/
84{
85 CUPS_RASTER_READ = 0, /* Open stream for reading */
86 CUPS_RASTER_WRITE = 1 /* Open stream for writing */
87} cups_mode_t;
88
89typedef enum cups_bool_e /**** Boolean type ****/
90{
91 CUPS_FALSE = 0, /* Logical false */
92 CUPS_TRUE = 1 /* Logical true */
93} cups_bool_t;
94
95typedef enum cups_jog_e /**** Jog attribute values ****/
96{
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 */
101} cups_jog_t;
102
103typedef enum cups_orient_e /**** Orientation attribute values ****/
104{
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 */
109} cups_orient_t;
110
111typedef enum cups_cut_e /**** CutMedia attribute values ****/
112{
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 */
118} cups_cut_t;
119
120typedef enum cups_adv_e /**** AdvanceMedia attribute values ****/
121{
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 */
127} cups_adv_t;
128
129typedef enum cups_edge_e /**** LeadingEdge attribute values ****/
130{
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 */
135} cups_edge_t;
136
137typedef enum cups_order_e /**** cupsColorOrder attribute values ****/
138{
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 ... */
142} cups_order_t;
143
144typedef enum cups_cspace_e /**** cupsColorSpace attribute values ****/
145{
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, *
156 * light-cyan, light-magenta */
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 */
162
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@ */
182} cups_cspace_t;
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...
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.
192 */
193
194typedef struct cups_page_header_s /**** Version 1 Page Header ****/
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
242/**** New in CUPS 1.2 ****/
243typedef struct cups_page_header2_s /**** Version 2 Page Header @since CUPS 1.2@ ****/
244{
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 ****/
252 unsigned AdvanceDistance; /* AdvanceDistance value in points */
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 */
257 unsigned HWResolution[2]; /* Resolution in dots-per-inch */
258 unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points) */
259 cups_bool_t InsertSheet; /* InsertSheet value */
260 cups_jog_t Jog; /* Jog value (see above) */
261 cups_edge_t LeadingEdge; /* LeadingEdge value (see above) */
262 unsigned Margins[2]; /* Lower-lefthand margins in points */
263 cups_bool_t ManualFeed; /* ManualFeed value */
264 unsigned MediaPosition; /* MediaPosition value */
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 */
271 unsigned PageSize[2]; /* Width and length of page in points */
272 cups_bool_t Separations; /* Separations value */
273 cups_bool_t TraySwitch; /* TraySwitch value */
274 cups_bool_t Tumble; /* Tumble value */
275
276 /**** CUPS Page Device Dictionary Values ****/
277 unsigned cupsWidth; /* Width of page image in pixels */
278 unsigned cupsHeight; /* Height of page image in pixels */
279 unsigned cupsMediaType; /* Media type code */
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 */
285 unsigned cupsCompression; /* Device compression to use */
286 unsigned cupsRowCount; /* Rows per band */
287 unsigned cupsRowFeed; /* Feed between bands */
288 unsigned cupsRowStep; /* Spacing between lines */
289
290 /**** Version 2 Dictionary Values ****/
fa73b229 291 unsigned cupsNumColors; /* Number of colors @since CUPS 1.2@ */
923edb68 292 float cupsBorderlessScalingFactor;
b423cd4c 293 /* Scaling that was applied to page data @since CUPS 1.2@ */
923edb68 294 float cupsPageSize[2]; /* Floating point PageSize (scaling *
295 * factor not applied) @since CUPS 1.2@ */
296 float cupsImagingBBox[4]; /* Floating point ImagingBoundingBox *
297 * (scaling factor not applied) @since CUPS 1.2@ */
fa73b229 298 unsigned cupsInteger[16]; /* User-defined integer values @since CUPS 1.2@ */
299 float cupsReal[16]; /* User-defined floating-point values @since CUPS 1.2@ */
300 char cupsString[16][64]; /* User-defined string values @since CUPS 1.2@ */
301 char cupsMarkerType[64]; /* Ink/toner type @since CUPS 1.2@ */
302 char cupsRenderingIntent[64];/* Color rendering intent @since CUPS 1.2@ */
303 char cupsPageSizeName[64]; /* PageSize name @since CUPS 1.2@ */
ef416fc2 304} cups_page_header2_t;
305
f301802f 306typedef struct _cups_raster_s cups_raster_t;
307 /**** Raster stream data ****/
ef416fc2 308
a74454a7 309typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits);
310
ef416fc2 311
312/*
313 * Prototypes...
314 */
315
316extern void cupsRasterClose(cups_raster_t *r);
317extern cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode);
318extern unsigned cupsRasterReadHeader(cups_raster_t *r,
319 cups_page_header_t *h);
320extern unsigned cupsRasterReadPixels(cups_raster_t *r,
321 unsigned char *p, unsigned len);
322extern unsigned cupsRasterWriteHeader(cups_raster_t *r,
323 cups_page_header_t *h);
324extern unsigned cupsRasterWritePixels(cups_raster_t *r,
325 unsigned char *p, unsigned len);
326
327/**** New in CUPS 1.2 ****/
328extern int cupsRasterInterpretPPD(cups_page_header2_t *h,
923edb68 329 ppd_file_t *ppd,
330 int num_options,
a74454a7 331 cups_option_t *options,
332 cups_interpret_cb_t func);
ef416fc2 333extern unsigned cupsRasterReadHeader2(cups_raster_t *r,
334 cups_page_header2_t *h);
335extern unsigned cupsRasterWriteHeader2(cups_raster_t *r,
336 cups_page_header2_t *h);
337
338# ifdef __cplusplus
339}
340# endif /* __cplusplus */
341
342#endif /* !_CUPS_RASTER_H_ */
343
344/*
f301802f 345 * End of "$Id: raster.h 5516 2006-05-11 23:54:05Z mike $".
ef416fc2 346 */