2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: ilconvert.h /main/3 1995/10/23 15:44:19 rswiston $ */
24 /**---------------------------------------------------------------------
26 *** (c)Copyright 1991 Hewlett-Packard Co.
28 *** RESTRICTED RIGHTS LEGEND
29 *** Use, duplication, or disclosure by the U.S. Government is subject to
30 *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
31 *** Technical Data and Computer Software clause in DFARS 252.227-7013.
32 *** Hewlett-Packard Company
33 *** 3000 Hanover Street
34 *** Palo Alto, CA 94304 U.S.A.
35 *** Rights for non-DOD U.S. Government Departments and Agencies are as set
36 *** forth in FAR 52.227-19(c)(1,2).
38 ***-------------------------------------------------------------------*/
47 /* Include file for /ilc/ilconvert.c and conversion code referenced by it;
48 only those files should include this file.
51 /* Values for ilConvertRec.srcFormatCode.
52 Format converters (those which would have ilConvertRec.pDstDes null
53 and ilConvertRec.pDstFormat non-null) MUST set IL_DONT_CHECK_STD_FORMAT.
54 Descriptor converters must set another code, which identifies the
55 required src format, as follows (fields not named are not checked):
57 IL_STD_FORMAT_BIT src format is IL_FORMAT_BIT: rowBitAlign
58 == 32; bitsPerSample[0] == 1.
59 IL_STD_FORMAT_BYTE src format is IL_FORMAT_BYTE:
60 bitsPerSample[0] == 8.
61 IL_STD_FORMAT_3BYTE_PIXEL src format is IL_FORMAT_3BYTE_PIXEL:
62 bitsPerSample[0,1,2] == 8; sampleOrder ==
65 #define IL_DONT_CHECK_STD_FORMAT 0
66 #define IL_STD_FORMAT_BIT 1
67 #define IL_STD_FORMAT_BYTE 2
68 #define IL_STD_FORMAT_3BYTE_PIXEL 3
70 /* Standard definition for a conversion filter added by ilConvert().
71 Basically the parameter values to be passed to ilAddPipeElement() to
72 add a given pipe converter. Some basic rules:
73 - the filter must take any stripHeight, and output the same
74 - it must not change the height/width of the image
75 - pDstDes and pDstFormat in the structure must point to the output
76 des/format, or be null if the output des/format is the
77 same as the input (can't both be null - that is no conversion!)
78 "srcFormatCode" is a code for the required src (input) format to
79 this element. See notes above.
80 The function "AddElement()" if non-null is called after the pipe
81 element is successfully added, as:
82 (*AddElement) (<pPrivate from ilAddPipeElement>, pPalette);
83 It can be used for example to init the private block with data
84 other than what might be done by Init().
87 ilError (*CheckFormat)(); /* reserved: MUST BE IL_NPF! */
88 unsigned int srcFormatCode; /* see above */
89 ilError (*AddElement)(); /* see above */
90 const ilImageDes *pDstDes; /* ptr to new des or null */
91 const ilImageFormat *pDstFormat; /* ptr to new format or null */
97 } ilConvertRec, *ilConvertPtr;
99 /* Standard definition for a format filter added by ilConvert().
100 Basically a subset of an ilConvertRec; see above.
103 ilError (*AddElement)(); /* see above */
104 unsigned int nBytesPrivate;
106 ilError (*Cleanup)();
107 ilError (*Destroy)();
108 ilError (*Execute)();
109 } ilFormatRec, *ilFormatPtr;
112 /* In /ilc/ildither.c : */
114 IL_EXTERN const unsigned int _ilDitherKernel[];
115 IL_EXTERN const unsigned short _ilMul8[];
116 IL_EXTERN const unsigned short _ilMul4[];
119 /* Convert from source type (pDes->type) == RGB to Palette.
120 pFormat points to the source format; on return, *pFormat is updated
121 to the dst format. *pDes ->the src (pipe) des; on return *pDes is the new des.
123 IL_EXTERN ilBool _ilConvertRGBToPalette (
127 ilImageFormat *pFormat,
129 ilConvertToPaletteInfo *pData
132 /* Dithers using error diffusion to bitonal.
133 Input image: IL_DES_GRAY, IL_FORMAT_BYTE.
134 Output image: IL_DES_BITONAL, IL_FORMAT_BIT
136 IL_EXTERN ilConvertRec _ilDiffuseGrayToBitonal;
138 /* Convert using a user-supplied threshold.
139 Input image: IL_DES_GRAY (either form of blackIsZero), IL_FORMAT_BYTE.
140 Output image: IL_DES_BITONAL, IL_FORMAT_BIT
142 IL_EXTERN ilConvertRec _ilThresholdGrayToBitonal;
144 /* In /ilc/ilpalette.c :
145 Converts byte palette image to RGB, each a byte
146 Input image: uncompressed IL_PALETTE, any # of levels, IL_FORMAT_3BYTE_PIXEL.
147 Output image: IL_DES_GRAY, IL_FORMAT_BYTE.
149 IL_EXTERN ilConvertRec _ilPaletteToRGBByte;
152 /* In /ilc/iltruegray.c :
153 Converts rgb image to gray scale.
154 Input image: uncompressed IL_RGB, any # of levels, IL_FORMAT_3BYTE_PIXEL.
155 Output image: IL_DES_GRAY, IL_FORMAT_BYTE.
157 IL_EXTERN ilConvertRec _ilRGBToGray;
159 /* In /ilc/iltruegray.c :
160 Converts gray scale image to rgb.
161 Input image: uncompressed IL_GRAY, any # of levels, IL_FORMAT_BYTE.
162 Output image: IL_DES_RGB, IL_FORMAT_3BYTE_PIXEL.
164 IL_EXTERN ilConvertRec _ilGrayToRGB;
166 /* In /ilc/ilformat.c :
167 Reformats image to change the rowBitAlign only.
169 IL_EXTERN ilFormatRec _ilFormatRowBitAlign;
171 /* Convert 4 to 8 bit or 8 to 4 bit per sample.
173 IL_EXTERN ilFormatRec _ilFormat4To8Bit;
175 IL_EXTERN ilFormatRec _ilFormat8To4Bit;
177 /* Reformat an 8 bit/pixel 3 sample planar image to pixel format.
179 IL_EXTERN ilFormatRec _ilFormat8Bit3PlaneToPixel;
181 /* Reformat an 8 bit/pixel 3 sample pixel image to planar format.
183 IL_EXTERN ilFormatRec _ilFormat8Bit3PixelToPlane;
185 /* In /ilc/ilformat.c :
186 Add a conversion filter to the given pipe which converts from the levels
187 in "*pPipeDes" (i.e. the levels of the current pipe image) to those in
188 "*pDes" (note - only nLevelsPerSample is reference from pDes).
189 If failure, declares pipe invalid (which sets error code) and returns false;
190 else returns true and "*pInfo", "*pPipeDes" and "*pFormat" are updated
191 with the new pipe state info.
193 IL_EXTERN ilBool _ilAddLevelConversionFilter (
196 ilImageDes *pPipeDes,
197 const ilImageDes *pDes,
198 ilImageFormat *pFormat
202 /* In /ilc/ilinvert.c :
203 Add a filter to invert a bitonal or gray image.
205 IL_EXTERN ilBool _ilAddInvertFilter (
207 ilImageDes *pPipedes,
211 /* In /ilc/ilupsample.c : */
213 /* Attempt to upsample and scale based on "scaleFactor" (0 = no scaling; 1 = double;
214 2 = 4x), or return false if it cannot be done with the given pipe image (in which
215 case pipe->context->error == 0) or if error occurs (error != 0). Pipe image
216 must be decompressed before calling this function.
218 IL_EXTERN ilBool _ilFastUpsample (
222 ilImageFormat *pFormat,
226 /* Upsample and / or convert to gray the pipe image which must be a YCbCr image.
227 If "toGray" is true, the Y plane only will be upsampled (or copied) resulting
228 in a gray image; else a planar YCbCr image will result.
229 If "upSample" is true must upsample; "upSample" and/or "toGray" must be true.
230 pFormat points to the source format; on return, *pFormat is updated
231 to the dst format, *pDes to the dst descriptor.
233 IL_EXTERN ilBool _ilUpsampleYCbCr (
237 ilImageFormat *pFormat,
242 /* In /ilc/ilycbcr.c : */
244 /* Subsample the pipe image which must be a fully upsampled YCbCr image.
245 pFormat points to the source format; on return, *pFormat is updated
246 to the dst format. *pDes to the _destination_ des, i.e. has subsample values.
248 IL_EXTERN ilBool _ilSubsampleYCbCr (
252 ilImageFormat *pFormat
255 /* Convert from source type (pDes->type) == IL_YCBCR to RBB.
256 The YCbCr image must already be upsampled.
257 pFormat points to the source format; on return, *pFormat is updated
258 to the dst format, *pDes to the dst descriptor.
260 IL_EXTERN ilBool _ilConvertYCbCrToRGB (
264 ilImageFormat *pFormat
267 /* Convert from source type (pDes->type) == RGB to YCbCr.
268 pFormat points to the source format; on return, *pFormat is updated
269 to the dst format. pNewDes points to the dst dest; *pDes to the src (pipe) des;
270 on return it is updated to the new descriptor.
272 IL_EXTERN ilBool _ilConvertRGBToYCbCr (
276 const ilImageDes *pNewDes,
277 ilImageFormat *pFormat
280 /* Does conversions of some forms of YCbCr to dithered IL_PALETTE.
281 Returns "true" if conversion handled, else "false" if not handled or if error.
282 The pipe image must be an uncompressed YCbCr image.
284 IL_EXTERN ilBool _ilDitherYCbCr (
288 ilImageFormat *pFormat,
290 ilConvertToPaletteInfo *pData