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: ilxpmP.h /main/4 1995/10/23 16:03:34 rswiston $ */
24 /* Copyright 1990,91 GROUPE BULL -- See licence conditions in file COPYRIGHT */
25 /*****************************************************************************\
29 * Private Include file *
31 * Developed by Arnaud Le Hors *
32 \*****************************************************************************/
38 /* memory leak control tool */
39 #include <mnemosyne.h>
44 #include "decw$include:Xlib.h"
45 #include "decw$include:Intrinsic.h"
46 #include "sys$library:stdio.h"
49 #include <X11/Intrinsic.h>
59 /* we keep the same codes as for Bitmap management */
63 #include "decw$include:Xutil.h"
65 #include <X11/Xutil.h>
81 char *Bcmt, *Ecmt, Bos, Eos;
82 unsigned int InsideString; /* used during parsing: 0 or 1
83 * whether we are inside or not */
90 typedef unsigned char byte;
97 char *type; /* key word */
98 char *Bcmt; /* string begining comments */
99 char *Ecmt; /* string ending comments */
100 char Bos; /* character begining strings */
101 char Eos; /* character ending strings */
102 char *Strs; /* strings separator */
103 char *Dec; /* data declaration string */
104 char *Boa; /* string begining assignment */
105 char *Eoa; /* string ending assignment */
108 extern xpmDataType xpmDataTypes[];
111 * rgb values and ascii names (from rgb text file) rgb values,
112 * range of 0 -> 65535 color mnemonic of rgb value
119 /* Maximum number of rgb mnemonics allowed in rgb text file. */
120 #define MAX_RGBNAMES 1024
122 extern char *xpmColorKeys[];
124 #define TRANSPARENT_COLOR "None" /* this must be a string! */
126 /* number of xpmColorKeys */
130 * key numbers for visual type, they must fit along with the number key of
131 * each corresponding element in xpmColorKeys[] defined in xpm.h
138 /* structure containing data related to an Xpm pixmap */
144 unsigned int ncolors;
146 unsigned int *pixelindex;
147 /* XColor *xcolors; */
149 unsigned int mask_pixel; /* mask pixel's colorTable index */
150 unsigned short *pPalette; /* color palette derived for xpm Image */
151 short nPaletteColors; /* current entry count in palette */
154 #define UNDEF_PIXEL 0x80000000
156 /* XPM private routines */
158 FUNC(xpmCreateImage, int, (ilObject object,
159 xpmInternAttrib * attrib,
160 ilClientImage * image_return,
161 ilClientImage * shapeimage_return,
162 XpmAttributes * attributes));
164 FUNC(xpmParseData, int, (xpmData * data,
165 xpmInternAttrib * attrib_return,
166 XpmAttributes * attributes));
169 FUNC(xpmScanImage, int, (Display * display,
172 XpmAttributes * attributes,
173 xpmInternAttrib * attrib));
175 FUNC(xpmVisualType, int, (Visual * visual));
178 FUNC(xpmFreeColorTable, int, (char ***colorTable, int ncolors));
180 FUNC(xpmInitInternAttrib, int, (xpmInternAttrib * coedata));
182 FUNC(xpmFreeInternAttrib, int, (xpmInternAttrib * coedata));
184 FUNC(xpmSetAttributes, int, (xpmInternAttrib * attrib,
185 XpmAttributes * attributes));
187 FUNC(xpmGetAttributes, int, (XpmAttributes * attributes,
188 xpmInternAttrib * attrib));
192 FUNC(xpmNextString, int, (xpmData * mdata));
193 FUNC(xpmNextUI, int, (xpmData * mdata, unsigned int *ui_return));
194 FUNC(xpmGetC, int, (xpmData * mdata));
195 FUNC(xpmUngetC, int, (int c, xpmData * mdata));
196 FUNC(xpmNextWord, unsigned int, (xpmData * mdata, char *buf));
197 FUNC(xpmGetCmt, int, (xpmData * mdata, char **cmt));
198 FUNC(xpmReadFile, int, (char *filename, xpmData * mdata));
199 FUNC(xpmWriteFile, int, (char *filename, xpmData * mdata));
200 FUNC(xpmOpenArray, int, (char **data, xpmData * mdata));
201 FUNC(XpmDataClose, int, (xpmData * mdata));
206 FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName * rgbn));
207 FUNC(xpmGetRgbName, char *, (xpmRgbName * rgbn, int rgbn_max,
208 int red, int green, int blue));
209 FUNC(xpmFreeRgbNames, void, (xpmRgbName * rgbn, int rgbn_max));
211 FUNC(xpm_xynormalizeimagebits, int, (unsigned char *bp,
213 FUNC(xpm_znormalizeimagebits, int, (unsigned char *bp,
219 * The XYNORMALIZE macro determines whether XY format data requires
220 * normalization and calls a routine to do so if needed. The logic in
221 * this module is designed for LSBFirst byte and bit order, so
222 * normalization is done as required to present the data in this order.
224 * The ZNORMALIZE macro performs byte and nibble order normalization if
225 * required for Z format data.
227 * The XYINDEX macro computes the index to the starting byte (char) boundary
228 * for a bitmap_unit containing a pixel with coordinates x and y for image
231 * The ZINDEX* macros compute the index to the starting byte (char) boundary
232 * for a pixel with coordinates x and y for image data in ZPixmap format.
237 #define XYNORMALIZE(bp, img) \
238 if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
239 xpm_xynormalizeimagebits((unsigned char *)(bp), img)
241 #define ZNORMALIZE(bp, img) \
242 if (img->byte_order == MSBFirst) \
243 xpm_znormalizeimagebits((unsigned char *)(bp), img)
245 #define XYINDEX(x, y, img) \
246 ((y) * img->bytes_per_line) + \
247 (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
249 #define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
250 (((x) * img->bits_per_pixel) >> 3)
252 #define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
254 #define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
256 #define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
258 #define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
263 #if defined(__STDC__)