File: image.h

package info (click to toggle)
cupsys 1.0.4-12
  • links: PTS
  • area: main
  • in suites: potato
  • size: 9,988 kB
  • ctags: 12,841
  • sloc: ansic: 110,263; makefile: 684; sh: 222; lisp: 60
file content (225 lines) | stat: -rw-r--r-- 6,796 bytes parent folder | download
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
222
223
224
225
/*
 * "$Id: image.h,v 1.8 1999/08/30 15:50:16 mike Exp $"
 *
 *   Image library definitions for the Common UNIX Printing System (CUPS).
 *
 *   Copyright 1993-1999 by Easy Software Products.
 *
 *   These coded instructions, statements, and computer programs are the
 *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
 *   at:
 *
 *       Attn: CUPS Licensing Information
 *       Easy Software Products
 *       44141 Airport View Drive, Suite 204
 *       Hollywood, Maryland 20636-3111 USA
 *
 *       Voice: (301) 373-9603
 *       EMail: cups-info@cups.org
 *         WWW: http://www.cups.org
 */

#ifndef _IMAGE_H_
#  define _IMAGE_H_

/*
 * Include necessary headers...
 */

#  include <stdio.h>
#  include <stdlib.h>
#  include <string.h>
#  include <errno.h>
#  include <config.h>


/*
 * Colorspaces...
 */

#  define IMAGE_CMYK	-4		/* Cyan, magenta, yellow, and black */
#  define IMAGE_CMY	-3		/* Cyan, magenta, and yellow */
#  define IMAGE_BLACK	-1		/* Black */
#  define IMAGE_WHITE	1		/* White (luminance) */
#  define IMAGE_RGB	3		/* Red, green, and blue */

/*
 * Tile definitions...
 */

#  define TILE_SIZE	256		/* 256x256 pixel tiles */
#  define 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 */


/*
 * Image byte type...
 */

typedef unsigned char ib_t;

/*
 * Tile cache structure...
 */

typedef struct ic_str
{
  struct ic_str	*prev,		/* Previous tile in cache */
		*next;		/* Next tile in cache */
  void		*tile;		/* Tile this is attached to */
  ib_t		*pixels;	/* Pixel data */
} ic_t;

/*
 * Tile structure...
 */

typedef struct
{
  int		dirty;		/* True if tile is dirty */
  long		pos;		/* Position of tile on disk (-1 if not written) */
  ic_t		*ic;		/* Pixel data */
} itile_t;

/*
 * Image structure...
 */

typedef struct
{
  int		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 */
  itile_t	**tiles;	/* Tiles in image */
  ic_t		*first,		/* First cached tile in image */
		*last;		/* Last cached tile in image */
  FILE		*cachefile;	/* Tile cache file */
  char		cachename[256];	/* Tile cache filename */
} image_t;

/*
 * Image row zooming structure...
 */

typedef struct
{
  image_t	*img;		/* Image to zoom */
  unsigned	xorig,
		yorig,
		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 */
  ib_t		*rows[2],	/* Horizontally scaled pixel data */
		*in;		/* Unscaled input pixel data */
} izoom_t;


/*
 * Basic image functions...
 */

extern image_t	*ImageOpen(char *filename, int primary, int secondary,
		           int saturation, int hue, const ib_t *lut);
extern void	ImageClose(image_t *img);
extern void	ImageSetMaxTiles(image_t *img, int max_tiles);
extern void	ImageSetProfile(float d, float g, float matrix[3][3]);

#define 	ImageGetDepth(img)	((img)->colorspace < 0 ? -(img)->colorspace : (img)->colorspace)
extern int	ImageGetCol(image_t *img, int x, int y, int height, ib_t *pixels);
extern int	ImageGetRow(image_t *img, int x, int y, int width, ib_t *pixels);
extern int	ImagePutCol(image_t *img, int x, int y, int height, const ib_t *pixels);
extern int	ImagePutRow(image_t *img, int x, int y, int width, const ib_t *pixels);

/*
 * File formats...
 */

extern int	ImageReadGIF(image_t *img, FILE *fp, int primary, int secondary,
		             int saturation, int hue, const ib_t *lut);
extern int	ImageReadJPEG(image_t *img, FILE *fp, int primary, int secondary,
		              int saturation, int hue, const ib_t *lut);
extern int	ImageReadPNG(image_t *img, FILE *fp, int primary, int secondary,
		             int saturation, int hue, const ib_t *lut);
extern int	ImageReadPNM(image_t *img, FILE *fp, int primary, int secondary,
		             int saturation, int hue, const ib_t *lut);
extern int	ImageReadPhotoCD(image_t *img, FILE *fp, int primary,
		                 int secondary, int saturation, int hue,
				 const ib_t *lut);
extern int	ImageReadSGI(image_t *img, FILE *fp, int primary, int secondary,
		             int saturation, int hue, const ib_t *lut);
extern int	ImageReadSunRaster(image_t *img, FILE *fp, int primary,
		                   int secondary, int saturation, int hue,
				   const ib_t *lut);
extern int	ImageReadTIFF(image_t *img, FILE *fp, int primary, int secondary,
		              int saturation, int hue, const ib_t *lut);

/*
 * Colorspace conversions...
 */

extern void	ImageWhiteToWhite(const ib_t *in, ib_t *out, int count);
extern void	ImageWhiteToRGB(const ib_t *in, ib_t *out, int count);
extern void	ImageWhiteToBlack(const ib_t *in, ib_t *out, int count);
extern void	ImageWhiteToCMY(const ib_t *in, ib_t *out, int count);
extern void	ImageWhiteToCMYK(const ib_t *in, ib_t *out, int count);

extern void	ImageRGBToWhite(const ib_t *in, ib_t *out, int count);
extern void	ImageRGBToRGB(const ib_t *in, ib_t *out, int count);
extern void	ImageRGBToBlack(const ib_t *in, ib_t *out, int count);
extern void	ImageRGBToCMY(const ib_t *in, ib_t *out, int count);
extern void	ImageRGBToCMYK(const ib_t *in, ib_t *out, int count);

extern void	ImageRGBAdjust(ib_t *pixels, int count, int saturation, int hue);

extern void	ImageLut(ib_t *pixels, int count, const ib_t *lut);

/*
 * Image scaling operations...
 */

extern izoom_t	*ImageZoomAlloc(image_t *img, int x0, int y0, int x1, int y1,
		                int xsize, int ysize, int rotated);
extern void	ImageZoomFill(izoom_t *z, int iy);
extern void	ImageZoomQFill(izoom_t *z, int iy);
extern void	ImageZoomFree(izoom_t *z);


#endif /* !_IMAGE_H_ */

/*
 * End of "$Id: image.h,v 1.8 1999/08/30 15:50:16 mike Exp $".
 */