Tizen 2.0 Release
[platform/upstream/cups-filters.git] / cupsfilters / image-private.h
1 /*
2  * "$Id$"
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 <config.h>
28 #  define DEBUG_printf(x)
29 #  define DEBUG_puts(x)
30 #  include <stdlib.h>
31 #  include <string.h>
32 #  include <ctype.h>
33 #  ifdef WIN32
34 #    include <io.h>
35 #  else
36 #    include <unistd.h>
37 #  endif /* WIN32 */
38 #  include <errno.h>
39 #  include <math.h>
40
41
42 /*
43  * Constants...
44  */
45
46 #  define CUPS_IMAGE_MAX_WIDTH  0x07ffffff
47                                         /* 2^27-1 to allow for 15-channel data */
48 #  define CUPS_IMAGE_MAX_HEIGHT 0x3fffffff
49                                         /* 2^30-1 */
50
51 #  define CUPS_TILE_SIZE        256     /* 256x256 pixel tiles */
52 #  define CUPS_TILE_MINIMUM     10      /* Minimum number of tiles */
53
54
55 /*
56  * min/max/abs macros...
57  */
58
59 #  ifndef max
60 #    define     max(a,b)        ((a) > (b) ? (a) : (b))
61 #  endif /* !max */
62 #  ifndef min
63 #    define     min(a,b)        ((a) < (b) ? (a) : (b))
64 #  endif /* !min */
65 #  ifndef abs
66 #    define     abs(a)          ((a) < 0 ? -(a) : (a))
67 #  endif /* !abs */
68
69
70 /*
71  * Types and structures...
72  */
73
74 typedef enum cups_iztype_e              /**** Image zoom type ****/
75 {
76   CUPS_IZOOM_FAST,                      /* Use nearest-neighbor sampling */
77   CUPS_IZOOM_NORMAL,                    /* Use bilinear interpolation */
78   CUPS_IZOOM_BEST                       /* Use bicubic interpolation */
79 } cups_iztype_t;
80
81 struct cups_ic_s;
82
83 typedef struct cups_itile_s             /**** Image tile ****/
84 {
85   int                   dirty;          /* True if tile is dirty */
86   off_t                 pos;            /* Position of tile on disk (-1 if not written) */
87   struct cups_ic_s      *ic;            /* Pixel data */
88 } cups_itile_t;
89
90 typedef struct cups_ic_s                /**** Image tile cache ****/
91 {
92   struct cups_ic_s      *prev,          /* Previous tile in cache */
93                         *next;          /* Next tile in cache */
94   cups_itile_t          *tile;          /* Tile this is attached to */
95   cups_ib_t             *pixels;        /* Pixel data */
96 } cups_ic_t;
97
98 struct cups_image_s                     /**** Image file data ****/
99 {
100   cups_icspace_t        colorspace;     /* Colorspace of image */
101   unsigned              xsize,          /* Width of image in pixels */
102                         ysize,          /* Height of image in pixels */
103                         xppi,           /* X resolution in pixels-per-inch */
104                         yppi,           /* Y resolution in pixels-per-inch */
105                         num_ics,        /* Number of cached tiles */
106                         max_ics;        /* Maximum number of cached tiles */
107   cups_itile_t          **tiles;        /* Tiles in image */
108   cups_ic_t             *first,         /* First cached tile in image */
109                         *last;          /* Last cached tile in image */
110   int                   cachefile;      /* Tile cache file */
111   char                  cachename[256]; /* Tile cache filename */
112 };
113
114 struct cups_izoom_s                     /**** Image zoom data ****/
115 {
116   cups_image_t          *img;           /* Image to zoom */
117   cups_iztype_t         type;           /* Type of zooming */
118   unsigned              xorig,          /* X origin */
119                         yorig,          /* Y origin */
120                         width,          /* Width of input area */
121                         height,         /* Height of input area */
122                         depth,          /* Number of bytes per pixel */
123                         rotated,        /* Non-zero if image needs to be rotated */
124                         xsize,          /* Width of output image */
125                         ysize,          /* Height of output image */
126                         xmax,           /* Maximum input image X position */
127                         ymax,           /* Maximum input image Y position */
128                         xmod,           /* Threshold for Bresenheim rounding */
129                         ymod;           /* ... */
130   int                   xstep,          /* Amount to step for each pixel along X */
131                         xincr,
132                         instep,         /* Amount to step pixel pointer along X */
133                         inincr,
134                         ystep,          /* Amount to step for each pixel along Y */
135                         yincr,
136                         row;            /* Current row */
137   cups_ib_t             *rows[2],       /* Horizontally scaled pixel data */
138                         *in;            /* Unscaled input pixel data */
139 };
140
141
142 /*
143  * Prototypes...
144  */
145
146 extern int              _cupsImagePutCol(cups_image_t *img, int x, int y,
147                                          int height, const cups_ib_t *pixels);
148 extern int              _cupsImagePutRow(cups_image_t *img, int x, int y,
149                                          int width, const cups_ib_t *pixels);
150 extern int              _cupsImageReadBMP(cups_image_t *img, FILE *fp,
151                                           cups_icspace_t primary,
152                                           cups_icspace_t secondary,
153                                           int saturation, int hue,
154                                           const cups_ib_t *lut);
155 extern int              _cupsImageReadFPX(cups_image_t *img, FILE *fp,
156                                           cups_icspace_t primary,
157                                           cups_icspace_t secondary,
158                                           int saturation, int hue,
159                                           const cups_ib_t *lut);
160 extern int              _cupsImageReadGIF(cups_image_t *img, FILE *fp,
161                                           cups_icspace_t primary,
162                                           cups_icspace_t secondary,
163                                           int saturation, int hue,
164                                           const cups_ib_t *lut);
165 extern int              _cupsImageReadJPEG(cups_image_t *img, FILE *fp,
166                                            cups_icspace_t primary,
167                                            cups_icspace_t secondary,
168                                            int saturation, int hue,
169                                            const cups_ib_t *lut);
170 extern int              _cupsImageReadPIX(cups_image_t *img, FILE *fp,
171                                           cups_icspace_t primary,
172                                           cups_icspace_t secondary,
173                                           int saturation, int hue,
174                                           const cups_ib_t *lut);
175 extern int              _cupsImageReadPNG(cups_image_t *img, FILE *fp,
176                                           cups_icspace_t primary,
177                                           cups_icspace_t secondary,
178                                           int saturation, int hue,
179                                           const cups_ib_t *lut);
180 extern int              _cupsImageReadPNM(cups_image_t *img, FILE *fp,
181                                           cups_icspace_t primary,
182                                           cups_icspace_t secondary,
183                                           int saturation, int hue,
184                                           const cups_ib_t *lut);
185 extern int              _cupsImageReadPhotoCD(cups_image_t *img, FILE *fp,
186                                               cups_icspace_t primary,
187                                               cups_icspace_t secondary,
188                                               int saturation, int hue,
189                                               const cups_ib_t *lut);
190 extern int              _cupsImageReadSGI(cups_image_t *img, FILE *fp,
191                                           cups_icspace_t primary,
192                                           cups_icspace_t secondary,
193                                           int saturation, int hue,
194                                           const cups_ib_t *lut);
195 extern int              _cupsImageReadSunRaster(cups_image_t *img, FILE *fp,
196                                                 cups_icspace_t primary,
197                                                 cups_icspace_t secondary,
198                                                 int saturation, int hue,
199                                                 const cups_ib_t *lut);
200 extern int              _cupsImageReadTIFF(cups_image_t *img, FILE *fp,
201                                            cups_icspace_t primary,
202                                            cups_icspace_t secondary,
203                                            int saturation, int hue,
204                                            const cups_ib_t *lut);
205 extern void             _cupsImageZoomDelete(cups_izoom_t *z);
206 extern void             _cupsImageZoomFill(cups_izoom_t *z, int iy);
207 extern cups_izoom_t     *_cupsImageZoomNew(cups_image_t *img, int xc0, int yc0,
208                                            int xc1, int yc1, int xsize,
209                                            int ysize, int rotated,
210                                            cups_iztype_t type);
211
212 extern int              _cupsRasterExecPS(cups_page_header2_t *h,
213                                           int *preferred_bits,
214                                           const char *code);
215 extern void             _cupsRasterAddError(const char *f, ...);
216 extern void             _cupsRasterClearError(void);
217
218 #endif /* !_CUPS_IMAGE_PRIVATE_H_ */
219
220 /*
221  * End of "$Id$".
222  */