lib/DtHelp/il: remove register keyword
[oweals/cde.git] / cde / lib / DtHelp / il / ilconvert.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: ilconvert.h /main/3 1995/10/23 15:44:19 rswiston $ */
24 /**---------------------------------------------------------------------
25 ***     
26 ***    (c)Copyright 1991 Hewlett-Packard Co.
27 ***    
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).
37 ***
38 ***-------------------------------------------------------------------*/
39
40 #ifndef ILCONVERT_H
41 #define ILCONVERT_H
42
43 #ifndef IL_H
44 #include "il.h"
45 #endif
46
47         /*  Include file for /ilc/ilconvert.c and conversion code referenced by it;
48             only those files should include this file.
49         */
50
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):
56
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 ==
63                                             IL_SAMPLE_PIXELS
64         */
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
69
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().
85         */
86 typedef struct {
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 */
92     size_t              nBytesPrivate;
93     ilError           (*Init)();
94     ilError           (*Cleanup)();
95     ilError           (*Destroy)();
96     ilError           (*Execute)();
97     } ilConvertRec, *ilConvertPtr;
98
99         /*  Standard definition for a format filter added by ilConvert().
100             Basically a subset of an ilConvertRec; see above.
101         */
102 typedef struct {
103     ilError           (*AddElement)();          /* see above */
104     unsigned int        nBytesPrivate;
105     ilError           (*Init)();
106     ilError           (*Cleanup)();
107     ilError           (*Destroy)();
108     ilError           (*Execute)();
109     } ilFormatRec, *ilFormatPtr;
110
111
112     /*  In /ilc/ildither.c : */
113
114 IL_EXTERN const unsigned int _ilDitherKernel[];
115 IL_EXTERN const unsigned short _ilMul8[];
116 IL_EXTERN const unsigned short _ilMul4[];
117
118
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.
122     */
123 IL_EXTERN ilBool _ilConvertRGBToPalette (
124     ilPipe                  pipe,
125     ilPipeInfo             *pInfo,
126     ilImageDes    *pDes,
127     ilImageFormat          *pFormat,
128     int                     option,
129     ilConvertToPaletteInfo *pData
130     );
131
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
135         */
136 IL_EXTERN ilConvertRec _ilDiffuseGrayToBitonal;
137
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
141         */
142 IL_EXTERN ilConvertRec _ilThresholdGrayToBitonal;
143
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.
148         */
149 IL_EXTERN ilConvertRec _ilPaletteToRGBByte;
150
151
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.
156         */
157 IL_EXTERN ilConvertRec _ilRGBToGray;
158
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.
163         */
164 IL_EXTERN ilConvertRec _ilGrayToRGB;
165
166         /*  In /ilc/ilformat.c :
167             Reformats image to change the rowBitAlign only.
168         */
169 IL_EXTERN ilFormatRec _ilFormatRowBitAlign;
170
171         /*  Convert 4 to 8 bit or 8 to 4 bit per sample.
172         */
173 IL_EXTERN ilFormatRec _ilFormat4To8Bit;
174
175 IL_EXTERN ilFormatRec _ilFormat8To4Bit;
176
177         /*  Reformat an 8 bit/pixel 3 sample planar image to pixel format.
178         */
179 IL_EXTERN ilFormatRec _ilFormat8Bit3PlaneToPixel;
180
181         /*  Reformat an 8 bit/pixel 3 sample pixel image to planar format.
182         */
183 IL_EXTERN ilFormatRec _ilFormat8Bit3PixelToPlane;
184
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.
192         */
193 IL_EXTERN ilBool _ilAddLevelConversionFilter (
194     ilPipe                  pipe,
195     ilPipeInfo             *pInfo,
196     ilImageDes             *pPipeDes,
197     const ilImageDes       *pDes,
198     ilImageFormat          *pFormat
199     );
200
201
202         /*  In /ilc/ilinvert.c :
203             Add a filter to invert a bitonal or gray image.
204         */
205 IL_EXTERN ilBool _ilAddInvertFilter (
206       ilPipe        pipe,
207       ilImageDes    *pPipedes,
208       ilPipeInfo    *pInfo
209       );
210
211     /*  In /ilc/ilupsample.c : */
212
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.
217     */
218 IL_EXTERN ilBool _ilFastUpsample (
219     ilPipe                  pipe,
220     ilPipeInfo             *pInfo,
221     ilImageDes             *pDes,
222     ilImageFormat          *pFormat,
223     int                     scaleFactor
224     );
225
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.
232     */
233 IL_EXTERN ilBool _ilUpsampleYCbCr (
234     ilPipe                  pipe,
235     ilPipeInfo             *pInfo,
236     ilImageDes             *pDes,
237     ilImageFormat          *pFormat,
238     ilBool                  toGray,
239     ilBool                  upSample
240     );
241
242     /*  In /ilc/ilycbcr.c : */
243
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.
247     */
248 IL_EXTERN ilBool _ilSubsampleYCbCr (
249     ilPipe                  pipe,
250     ilPipeInfo             *pInfo,
251     ilImageDes             *pDes,
252     ilImageFormat          *pFormat
253     );
254
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.
259     */
260 IL_EXTERN ilBool _ilConvertYCbCrToRGB (
261     ilPipe                  pipe,
262     ilPipeInfo             *pInfo,
263     ilImageDes             *pDes,
264     ilImageFormat          *pFormat
265     );
266
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.
271     */
272 IL_EXTERN ilBool _ilConvertRGBToYCbCr (
273     ilPipe                  pipe,
274     ilPipeInfo             *pInfo,
275     ilImageDes             *pDes,
276     const ilImageDes *pNewDes,
277     ilImageFormat          *pFormat
278     );
279
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.
283     */
284 IL_EXTERN ilBool _ilDitherYCbCr (
285     ilPipe                  pipe,
286     ilPipeInfo             *pInfo,
287     ilImageDes             *pDes,
288     ilImageFormat          *pFormat,
289     int                     option,
290     ilConvertToPaletteInfo *pData
291     );
292
293 #endif