]>
git.ipfire.org Git - thirdparty/cups.git/blob - filter/image-pix.c
2 * "$Id: image-pix.c,v 1.4 2002/01/02 17:58:58 mike Exp $"
4 * Alias PIX image routines for the Common UNIX Printing System (CUPS).
6 * Copyright 1993-2002 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * ImageReadPIX() - Read a PIX image file.
27 * read_short() - Read a 16-bit integer.
31 * Include necessary headers...
41 static short read_short(FILE *fp
);
45 * 'ImageReadPIX()' - Read a PIX image file.
48 int /* O - Read status */
49 ImageReadPIX(image_t
*img
, /* IO - Image */
50 FILE *fp
, /* I - Image file */
51 int primary
, /* I - Primary choice for colorspace */
52 int secondary
, /* I - Secondary choice for colorspace */
53 int saturation
, /* I - Color saturation (%) */
54 int hue
, /* I - Color hue (degrees) */
55 const ib_t
*lut
) /* I - Lookup table for gamma/brightness */
57 short width
, /* Width of image */
58 height
, /* Height of image */
59 depth
; /* Depth of image (bits) */
60 int count
, /* Repetition count */
61 bpp
, /* Bytes per pixel */
62 x
, y
; /* Looping vars */
63 ib_t r
, g
, b
; /* Red, green/gray, blue values */
64 ib_t
*in
, /* Input pixels */
65 *out
, /* Output pixels */
66 *ptr
; /* Pointer into pixels */
70 * Get the image dimensions and setup the image...
73 width
= read_short(fp
);
74 height
= read_short(fp
);
77 depth
= read_short(fp
);
80 img
->colorspace
= secondary
;
82 img
->colorspace
= primary
;
87 ImageSetMaxTiles(img
, 0);
89 in
= malloc(img
->xsize
* (depth
/ 8));
90 bpp
= ImageGetDepth(img
);
91 out
= malloc(img
->xsize
* bpp
);
94 * Read the image data...
99 for (count
= 0, y
= 0, g
= 0; y
< img
->ysize
; y
++)
101 if (img
->colorspace
== IMAGE_WHITE
)
106 for (x
= img
->xsize
; x
> 0; x
--, count
--)
117 if (img
->colorspace
!= IMAGE_WHITE
)
118 switch (img
->colorspace
)
121 ImageWhiteToRGB(in
, out
, img
->xsize
);
124 ImageWhiteToBlack(in
, out
, img
->xsize
);
127 ImageWhiteToCMY(in
, out
, img
->xsize
);
130 ImageWhiteToCMYK(in
, out
, img
->xsize
);
135 ImageLut(out
, img
->xsize
* bpp
, lut
);
137 ImagePutRow(img
, 0, y
, img
->xsize
, out
);
142 for (count
= 0, y
= 0, r
= 0, g
= 0, b
= 0; y
< img
->ysize
; y
++)
144 if (img
->colorspace
== IMAGE_RGB
)
149 for (x
= img
->xsize
; x
> 0; x
--, count
--)
164 if (img
->colorspace
== IMAGE_RGB
)
166 if (saturation
!= 100 || hue
!= 0)
167 ImageRGBAdjust(out
, img
->xsize
, saturation
, hue
);
171 if (saturation
!= 100 || hue
!= 0)
172 ImageRGBAdjust(in
, img
->xsize
, saturation
, hue
);
174 switch (img
->colorspace
)
177 ImageRGBToWhite(in
, out
, img
->xsize
);
180 ImageRGBToBlack(in
, out
, img
->xsize
);
183 ImageRGBToCMY(in
, out
, img
->xsize
);
186 ImageRGBToCMYK(in
, out
, img
->xsize
);
192 ImageLut(out
, img
->xsize
* bpp
, lut
);
194 ImagePutRow(img
, 0, y
, img
->xsize
, out
);
207 * 'read_short()' - Read a 16-bit integer.
210 static short /* O - Value from file */
211 read_short(FILE *fp
) /* I - File to read from */
213 int ch
; /* Character from file */
217 return ((ch
<< 8) | getc(fp
));
222 * End of "$Id: image-pix.c,v 1.4 2002/01/02 17:58:58 mike Exp $".