]>
git.saurik.com Git - wxWidgets.git/blob - src/xpm/xpm34p.h
31a700848437c21de4310ee2d5168ed09ea1993e
2 * Copyright (C) 1989-94 GROUPE BULL
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * Except as contained in this notice, the name of GROUPE BULL shall not be
22 * used in advertising or otherwise to promote the sale, use or other dealings
23 * in this Software without prior written authorization from GROUPE BULL.
26 /*****************************************************************************\
30 * Private Include file *
32 * Developed by Arnaud Le Hors *
33 \*****************************************************************************/
36 * The code related to FOR_MSW has been added by
37 * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
46 * lets try to solve include files
50 #include "sys$library:stdio.h"
51 #include "sys$library:string.h"
56 /* stdio.h doesn't declare popen on a Sequent DYNIX OS */
61 #if defined(SYSV) || defined(SVR4)
69 #define rindex strrchr
72 #else /* defined(SYSV) || defined(SVR4) */
79 #if (defined(SYSV) || defined(SVR4) || defined(VMS)) && !defined(__sgi)
80 #define bcopy(source, dest, count) memcpy(dest, source, count)
81 #define bzero(b, len) memset(b, 0, len)
85 /* the following should help people wanting to use their own functions */
87 #define XpmMalloc(size) malloc((size))
88 #define XpmRealloc(ptr, size) realloc((ptr), (size))
89 #define XpmCalloc(nelem, elsize) calloc((nelem), (elsize))
91 /* checks for mallocs bigger than 64K */
92 #define XpmMalloc(size) boundCheckingMalloc((long)(size))/* in simx.[ch] */
93 #define XpmRealloc(ptr, size) boundCheckingRealloc((ptr),(long)(size))
94 #define XpmCalloc(nelem, elsize) \
95 boundCheckingCalloc((long)(nelem),(long) (elsize))
108 char Comment
[BUFSIZ
];
109 char *Bcmt
, *Ecmt
, Bos
, Eos
;
110 int format
; /* 1 if XPM1, 0 otherwise */
123 char *type
; /* key word */
124 char *Bcmt
; /* string beginning comments */
125 char *Ecmt
; /* string ending comments */
126 char Bos
; /* character beginning strings */
127 char Eos
; /* character ending strings */
128 char *Strs
; /* strings separator */
129 char *Dec
; /* data declaration string */
130 char *Boa
; /* string beginning assignment */
131 char *Eoa
; /* string ending assignment */
134 extern xpmDataType xpmDataTypes
[];
137 * rgb values and ascii names (from rgb text file) rgb values,
138 * range of 0 -> 65535 color mnemonic of rgb value
145 /* Maximum number of rgb mnemonics allowed in rgb text file. */
146 #define MAX_RGBNAMES 1024
148 extern char *xpmColorKeys
[];
150 #define TRANSPARENT_COLOR "None" /* this must be a string! */
152 /* number of xpmColorKeys */
155 /* XPM private routines */
157 FUNC(xpmWriteData
, int, (xpmData
*mdata
, XpmImage
*image
, char *name
,
160 FUNC(xpmParseData
, int, (xpmData
*data
, XpmImage
*image
, XpmInfo
*info
));
162 FUNC(xpmFreeColorTable
, void, (XpmColor
*colorTable
, int ncolors
));
164 FUNC(xpmInitAttributes
, void, (XpmAttributes
*attributes
));
166 FUNC(xpmInitXpmImage
, void, (XpmImage
*image
));
168 FUNC(xpmInitXpmInfo
, void, (XpmInfo
*info
));
170 FUNC(xpmSetInfoMask
, void, (XpmInfo
*info
, XpmAttributes
*attributes
));
171 FUNC(xpmSetInfo
, void, (XpmInfo
*info
, XpmAttributes
*attributes
));
172 FUNC(xpmSetAttributes
, void, (XpmAttributes
*attributes
, XpmImage
*image
,
176 FUNC(xpmCreatePixmapFromImage
, void, (Display
*display
, Drawable d
,
177 XImage
*ximage
, Pixmap
*pixmap_return
));
179 FUNC(xpmCreateImageFromPixmap
, void, (Display
*display
, Pixmap pixmap
,
180 XImage
**ximage_return
,
182 unsigned int *height
));
187 FUNC(xpmNextString
, int, (xpmData
*mdata
));
188 FUNC(xpmNextUI
, int, (xpmData
*mdata
, unsigned int *ui_return
));
189 FUNC(xpmGetString
, int, (xpmData
*mdata
, char **sptr
, unsigned int *l
));
191 #define xpmGetC(mdata) \
192 ((!mdata->type || mdata->type == XPMBUFFER) ? \
193 (*mdata->cptr++) : (getc(mdata->stream.file)))
195 FUNC(xpmNextWord
, unsigned int,
196 (xpmData
*mdata
, char *buf
, unsigned int buflen
));
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
, void, (char **data
, xpmData
*mdata
));
201 FUNC(xpmDataClose
, int, (xpmData
*mdata
));
202 FUNC(xpmParseHeader
, int, (xpmData
*mdata
));
203 FUNC(xpmOpenBuffer
, void, (char *buffer
, xpmData
*mdata
));
207 FUNC(xpmReadRgbNames
, int, (char *rgb_fname
, xpmRgbName
*rgbn
));
208 FUNC(xpmGetRgbName
, char *, (xpmRgbName
*rgbn
, int rgbn_max
,
209 int red
, int green
, int blue
));
210 FUNC(xpmFreeRgbNames
, void, (xpmRgbName
*rgbn
, int rgbn_max
));
212 FUNC(xpmGetRGBfromName
,int, (char *name
, int *r
, int *g
, int *b
));
215 FUNC(xpm_xynormalizeimagebits
, void, (register unsigned char *bp
,
216 register XImage
*img
));
217 FUNC(xpm_znormalizeimagebits
, void, (register unsigned char *bp
,
218 register XImage
*img
));
223 * The XYNORMALIZE macro determines whether XY format data requires
224 * normalization and calls a routine to do so if needed. The logic in
225 * this module is designed for LSBFirst byte and bit order, so
226 * normalization is done as required to present the data in this order.
228 * The ZNORMALIZE macro performs byte and nibble order normalization if
229 * required for Z format data.
231 * The XYINDEX macro computes the index to the starting byte (char) boundary
232 * for a bitmap_unit containing a pixel with coordinates x and y for image
235 * The ZINDEX* macros compute the index to the starting byte (char) boundary
236 * for a pixel with coordinates x and y for image data in ZPixmap format.
240 #define XYNORMALIZE(bp, img) \
241 if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
242 xpm_xynormalizeimagebits((unsigned char *)(bp), img)
244 #define ZNORMALIZE(bp, img) \
245 if (img->byte_order == MSBFirst) \
246 xpm_znormalizeimagebits((unsigned char *)(bp), img)
248 #define XYINDEX(x, y, img) \
249 ((y) * img->bytes_per_line) + \
250 (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
252 #define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
253 (((x) * img->bits_per_pixel) >> 3)
255 #define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
257 #define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
259 #define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
261 #define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
270 * there are structures and functions related to hastable code
273 typedef struct _xpmHashAtom
{
282 xpmHashAtom
*atomTable
;
285 FUNC(xpmHashTableInit
, int, (xpmHashTable
*table
));
286 FUNC(xpmHashTableFree
, void, (xpmHashTable
*table
));
287 FUNC(xpmHashSlot
, xpmHashAtom
*, (xpmHashTable
*table
, char *s
));
288 FUNC(xpmHashIntern
, int, (xpmHashTable
*table
, char *tag
, void *data
));
290 #define HashAtomData(i) ((void *)i)
291 #define HashColorIndex(slot) ((unsigned int)((*slot)->data))
292 #define USE_HASHTABLE (cpp > 2 && ncolors > 4)
295 FUNC(strdup
, char *, (char *s1
));
298 #ifdef NEED_STRCASECMP
299 FUNC(strcasecmp
, int, (char *s1
, char *s2
));
302 FUNC(atoui
, unsigned int, (char *p
, unsigned int l
, unsigned int *ui_return
));