]> git.ipfire.org Git - thirdparty/cups.git/blob - filter/image-private.h
Merge changes from CUPS 1.5.1-r9875.
[thirdparty/cups.git] / filter / image-private.h
1 /*
2 * "$Id: image-private.h 7473 2008-04-21 17:51:58Z mike $"
3 *
4 * Private image library definitions for CUPS.
5 *
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1993-2006 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 */
17
18 #ifndef _CUPS_IMAGE_PRIVATE_H_
19 # define _CUPS_IMAGE_PRIVATE_H_
20
21 /*
22 * Include necessary headers...
23 */
24
25 # include "image.h"
26 # include <cups/cups.h>
27 # include <cups/debug-private.h>
28 # include <cups/string-private.h>
29 # include <stdlib.h>
30 # include <string.h>
31 # ifdef WIN32
32 # include <io.h>
33 # else
34 # include <unistd.h>
35 # endif /* WIN32 */
36 # include <errno.h>
37 # include <math.h>
38
39
40 /*
41 * Constants...
42 */
43
44 # define CUPS_IMAGE_MAX_WIDTH 0x07ffffff
45 /* 2^27-1 to allow for 15-channel data */
46 # define CUPS_IMAGE_MAX_HEIGHT 0x3fffffff
47 /* 2^30-1 */
48
49 # define CUPS_TILE_SIZE 256 /* 256x256 pixel tiles */
50 # define CUPS_TILE_MINIMUM 10 /* Minimum number of tiles */
51
52
53 /*
54 * min/max/abs macros...
55 */
56
57 # ifndef max
58 # define max(a,b) ((a) > (b) ? (a) : (b))
59 # endif /* !max */
60 # ifndef min
61 # define min(a,b) ((a) < (b) ? (a) : (b))
62 # endif /* !min */
63 # ifndef abs
64 # define abs(a) ((a) < 0 ? -(a) : (a))
65 # endif /* !abs */
66
67
68 /*
69 * Types and structures...
70 */
71
72 typedef enum cups_iztype_e /**** Image zoom type ****/
73 {
74 CUPS_IZOOM_FAST, /* Use nearest-neighbor sampling */
75 CUPS_IZOOM_NORMAL, /* Use bilinear interpolation */
76 CUPS_IZOOM_BEST /* Use bicubic interpolation */
77 } cups_iztype_t;
78
79 struct cups_ic_s;
80
81 typedef struct cups_itile_s /**** Image tile ****/
82 {
83 int dirty; /* True if tile is dirty */
84 off_t pos; /* Position of tile on disk (-1 if not written) */
85 struct cups_ic_s *ic; /* Pixel data */
86 } cups_itile_t;
87
88 typedef struct cups_ic_s /**** Image tile cache ****/
89 {
90 struct cups_ic_s *prev, /* Previous tile in cache */
91 *next; /* Next tile in cache */
92 cups_itile_t *tile; /* Tile this is attached to */
93 cups_ib_t *pixels; /* Pixel data */
94 } cups_ic_t;
95
96 struct cups_image_s /**** Image file data ****/
97 {
98 cups_icspace_t colorspace; /* Colorspace of image */
99 unsigned xsize, /* Width of image in pixels */
100 ysize, /* Height of image in pixels */
101 xppi, /* X resolution in pixels-per-inch */
102 yppi, /* Y resolution in pixels-per-inch */
103 num_ics, /* Number of cached tiles */
104 max_ics; /* Maximum number of cached tiles */
105 cups_itile_t **tiles; /* Tiles in image */
106 cups_ic_t *first, /* First cached tile in image */
107 *last; /* Last cached tile in image */
108 int cachefile; /* Tile cache file */
109 char cachename[256]; /* Tile cache filename */
110 };
111
112 struct cups_izoom_s /**** Image zoom data ****/
113 {
114 cups_image_t *img; /* Image to zoom */
115 cups_iztype_t type; /* Type of zooming */
116 unsigned xorig, /* X origin */
117 yorig, /* Y origin */
118 width, /* Width of input area */
119 height, /* Height of input area */
120 depth, /* Number of bytes per pixel */
121 rotated, /* Non-zero if image needs to be rotated */
122 xsize, /* Width of output image */
123 ysize, /* Height of output image */
124 xmax, /* Maximum input image X position */
125 ymax, /* Maximum input image Y position */
126 xmod, /* Threshold for Bresenheim rounding */
127 ymod; /* ... */
128 int xstep, /* Amount to step for each pixel along X */
129 xincr,
130 instep, /* Amount to step pixel pointer along X */
131 inincr,
132 ystep, /* Amount to step for each pixel along Y */
133 yincr,
134 row; /* Current row */
135 cups_ib_t *rows[2], /* Horizontally scaled pixel data */
136 *in; /* Unscaled input pixel data */
137 };
138
139
140 /*
141 * Prototypes...
142 */
143
144 extern int _cupsImagePutCol(cups_image_t *img, int x, int y,
145 int height, const cups_ib_t *pixels);
146 extern int _cupsImagePutRow(cups_image_t *img, int x, int y,
147 int width, const cups_ib_t *pixels);
148 extern int _cupsImageReadBMP(cups_image_t *img, FILE *fp,
149 cups_icspace_t primary,
150 cups_icspace_t secondary,
151 int saturation, int hue,
152 const cups_ib_t *lut);
153 extern int _cupsImageReadFPX(cups_image_t *img, FILE *fp,
154 cups_icspace_t primary,
155 cups_icspace_t secondary,
156 int saturation, int hue,
157 const cups_ib_t *lut);
158 extern int _cupsImageReadGIF(cups_image_t *img, FILE *fp,
159 cups_icspace_t primary,
160 cups_icspace_t secondary,
161 int saturation, int hue,
162 const cups_ib_t *lut);
163 extern int _cupsImageReadJPEG(cups_image_t *img, FILE *fp,
164 cups_icspace_t primary,
165 cups_icspace_t secondary,
166 int saturation, int hue,
167 const cups_ib_t *lut);
168 extern int _cupsImageReadPIX(cups_image_t *img, FILE *fp,
169 cups_icspace_t primary,
170 cups_icspace_t secondary,
171 int saturation, int hue,
172 const cups_ib_t *lut);
173 extern int _cupsImageReadPNG(cups_image_t *img, FILE *fp,
174 cups_icspace_t primary,
175 cups_icspace_t secondary,
176 int saturation, int hue,
177 const cups_ib_t *lut);
178 extern int _cupsImageReadPNM(cups_image_t *img, FILE *fp,
179 cups_icspace_t primary,
180 cups_icspace_t secondary,
181 int saturation, int hue,
182 const cups_ib_t *lut);
183 extern int _cupsImageReadPhotoCD(cups_image_t *img, FILE *fp,
184 cups_icspace_t primary,
185 cups_icspace_t secondary,
186 int saturation, int hue,
187 const cups_ib_t *lut);
188 extern int _cupsImageReadSGI(cups_image_t *img, FILE *fp,
189 cups_icspace_t primary,
190 cups_icspace_t secondary,
191 int saturation, int hue,
192 const cups_ib_t *lut);
193 extern int _cupsImageReadSunRaster(cups_image_t *img, FILE *fp,
194 cups_icspace_t primary,
195 cups_icspace_t secondary,
196 int saturation, int hue,
197 const cups_ib_t *lut);
198 extern int _cupsImageReadTIFF(cups_image_t *img, FILE *fp,
199 cups_icspace_t primary,
200 cups_icspace_t secondary,
201 int saturation, int hue,
202 const cups_ib_t *lut);
203 extern void _cupsImageZoomDelete(cups_izoom_t *z);
204 extern void _cupsImageZoomFill(cups_izoom_t *z, int iy);
205 extern cups_izoom_t *_cupsImageZoomNew(cups_image_t *img, int xc0, int yc0,
206 int xc1, int yc1, int xsize,
207 int ysize, int rotated,
208 cups_iztype_t type);
209
210 extern int _cupsRasterExecPS(cups_page_header2_t *h,
211 int *preferred_bits,
212 const char *code);
213 extern void _cupsRasterAddError(const char *f, ...);
214 extern void _cupsRasterClearError(void);
215
216 #endif /* !_CUPS_IMAGE_PRIVATE_H_ */
217
218 /*
219 * End of "$Id: image-private.h 7473 2008-04-21 17:51:58Z mike $".
220 */