File: image-private.h

package info (click to toggle)
cups 1.4.4-7+squeeze10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 25,548 kB
  • ctags: 9,583
  • sloc: ansic: 138,214; sh: 37,926; cpp: 25,469; makefile: 3,285; perl: 190; python: 127; php: 28
file content (221 lines) | stat: -rw-r--r-- 7,299 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
 * "$Id: image-private.h 8771 2009-08-20 18:14:49Z mike $"
 *
 *   Private image library definitions for the Common UNIX Printing
 *   System (CUPS).
 *
 *   Copyright 2007-2008 by Apple Inc.
 *   Copyright 1993-2006 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are the
 *   property of Apple Inc. and are protected by Federal copyright
 *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
 *   which should have been included with this file.  If this file is
 *   file is missing or damaged, see the license at "http://www.cups.org/".
 *
 *   This file is subject to the Apple OS-Developed Software exception.
 */

#ifndef _CUPS_IMAGE_PRIVATE_H_
#  define _CUPS_IMAGE_PRIVATE_H_

/*
 * Include necessary headers...
 */

#  include "image.h"
#  include <cups/cups.h>
#  include <cups/debug.h>
#  include <cups/string.h>
#  include <stdlib.h>
#  include <string.h>
#  ifdef WIN32
#    include <io.h>
#  else
#    include <unistd.h>
#  endif /* WIN32 */
#  include <errno.h>
#  include <math.h>


/*
 * Constants...
 */

#  define CUPS_IMAGE_MAX_WIDTH	0x07ffffff
					/* 2^27-1 to allow for 15-channel data */
#  define CUPS_IMAGE_MAX_HEIGHT	0x3fffffff
					/* 2^30-1 */

#  define CUPS_TILE_SIZE	256	/* 256x256 pixel tiles */
#  define CUPS_TILE_MINIMUM	10	/* Minimum number of tiles */


/*
 * min/max/abs macros...
 */

#  ifndef max
#    define 	max(a,b)	((a) > (b) ? (a) : (b))
#  endif /* !max */
#  ifndef min
#    define 	min(a,b)	((a) < (b) ? (a) : (b))
#  endif /* !min */
#  ifndef abs
#    define	abs(a)		((a) < 0 ? -(a) : (a))
#  endif /* !abs */


/*
 * Types and structures...
 */

typedef enum cups_iztype_e		/**** Image zoom type ****/
{
  CUPS_IZOOM_FAST,			/* Use nearest-neighbor sampling */
  CUPS_IZOOM_NORMAL,			/* Use bilinear interpolation */
  CUPS_IZOOM_BEST			/* Use bicubic interpolation */
} cups_iztype_t;

struct cups_ic_s;

typedef struct cups_itile_s		/**** Image tile ****/
{
  int			dirty;		/* True if tile is dirty */
  off_t			pos;		/* Position of tile on disk (-1 if not written) */
  struct cups_ic_s	*ic;		/* Pixel data */
} cups_itile_t;

typedef struct cups_ic_s		/**** Image tile cache ****/
{
  struct cups_ic_s	*prev,		/* Previous tile in cache */
			*next;		/* Next tile in cache */
  cups_itile_t		*tile;		/* Tile this is attached to */
  cups_ib_t		*pixels;	/* Pixel data */
} cups_ic_t;

struct cups_image_s			/**** Image file data ****/
{
  cups_icspace_t	colorspace;	/* Colorspace of image */
  unsigned		xsize,		/* Width of image in pixels */
			ysize,		/* Height of image in pixels */
			xppi,		/* X resolution in pixels-per-inch */
			yppi,		/* Y resolution in pixels-per-inch */
			num_ics,	/* Number of cached tiles */
			max_ics;	/* Maximum number of cached tiles */
  cups_itile_t		**tiles;	/* Tiles in image */
  cups_ic_t		*first,		/* First cached tile in image */
			*last;		/* Last cached tile in image */
  int			cachefile;	/* Tile cache file */
  char			cachename[256];	/* Tile cache filename */
};

struct cups_izoom_s			/**** Image zoom data ****/
{
  cups_image_t		*img;		/* Image to zoom */
  cups_iztype_t		type;		/* Type of zooming */
  unsigned		xorig,		/* X origin */
			yorig,		/* Y origin */
			width,		/* Width of input area */
			height,		/* Height of input area */
			depth,		/* Number of bytes per pixel */
			rotated,	/* Non-zero if image needs to be rotated */
			xsize,		/* Width of output image */
			ysize,		/* Height of output image */
			xmax,		/* Maximum input image X position */
			ymax,		/* Maximum input image Y position */
			xmod,		/* Threshold for Bresenheim rounding */
			ymod;		/* ... */
  int			xstep,		/* Amount to step for each pixel along X */
			xincr,
			instep,		/* Amount to step pixel pointer along X */
			inincr,
			ystep,		/* Amount to step for each pixel along Y */
			yincr,
			row;		/* Current row */
  cups_ib_t		*rows[2],	/* Horizontally scaled pixel data */
			*in;		/* Unscaled input pixel data */
};


/*
 * Prototypes...
 */

extern int		_cupsImagePutCol(cups_image_t *img, int x, int y,
			                 int height, const cups_ib_t *pixels);
extern int		_cupsImagePutRow(cups_image_t *img, int x, int y,
			                 int width, const cups_ib_t *pixels);
extern int		_cupsImageReadBMP(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadFPX(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadGIF(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadJPEG(cups_image_t *img, FILE *fp,
			                   cups_icspace_t primary,
					   cups_icspace_t secondary,
			                   int saturation, int hue,
					   const cups_ib_t *lut);
extern int		_cupsImageReadPIX(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadPNG(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadPNM(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadPhotoCD(cups_image_t *img, FILE *fp,
			                      cups_icspace_t primary,
			                      cups_icspace_t secondary,
					      int saturation, int hue,
					      const cups_ib_t *lut);
extern int		_cupsImageReadSGI(cups_image_t *img, FILE *fp,
			                  cups_icspace_t primary,
					  cups_icspace_t secondary,
			                  int saturation, int hue,
					  const cups_ib_t *lut);
extern int		_cupsImageReadSunRaster(cups_image_t *img, FILE *fp,
			                        cups_icspace_t primary,
			                        cups_icspace_t secondary,
						int saturation, int hue,
					        const cups_ib_t *lut);
extern int		_cupsImageReadTIFF(cups_image_t *img, FILE *fp,
			                   cups_icspace_t primary,
					   cups_icspace_t secondary,
			                   int saturation, int hue,
					   const cups_ib_t *lut);
extern void		_cupsImageZoomDelete(cups_izoom_t *z);
extern void		_cupsImageZoomFill(cups_izoom_t *z, int iy);
extern cups_izoom_t	*_cupsImageZoomNew(cups_image_t *img, int xc0, int yc0,
			                   int xc1, int yc1, int xsize,
					   int ysize, int rotated,
					   cups_iztype_t type);

extern int		_cupsRasterExecPS(cups_page_header2_t *h,
			                  int *preferred_bits,
			                  const char *code);
extern void		_cupsRasterAddError(const char *f, ...);
extern void		_cupsRasterClearError(void);

#endif /* !_CUPS_IMAGE_PRIVATE_H_ */

/*
 * End of "$Id: image-private.h 8771 2009-08-20 18:14:49Z mike $".
 */