2 * Copyright (C) 1989-95 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 /*****************************************************************************\
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
41 * The code related to AMIGA has been added by
42 * Lorens Younes (d93-hyo@nada.kth.se) 4/96
49 * first some identification numbers:
50 * the version and revision numbers are determined with the following rule:
51 * SO Major number = LIB minor version number.
52 * SO Minor number = LIB sub-minor version number.
53 * e.g: Xpm version 3.2f
54 * we forget the 3 which is the format number, 2 gives 2, and f gives 6.
55 * thus we have XpmVersion = 2 and XpmRevision = 6
56 * which gives SOXPMLIBREV = 2.6
58 * Then the XpmIncludeVersion number is built from these numbers.
62 #define XpmRevision 11
63 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
68 # define SYSV /* uses memcpy string.h etc. */
70 # include "simx.h" /* defines some X stuff using MSW types */
71 #define NEED_STRCASECMP /* at least for MSVC++ */
75 # else /* not AMIGA */
76 # include <X11/Xlib.h>
77 # include <X11/Xutil.h>
78 # endif /* not AMIGA */
81 /* let's define Pixel if it is not done yet */
82 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
83 typedef unsigned long Pixel; /* Index into colormap */
84 # define PIXEL_ALREADY_TYPEDEFED
87 /* Return ErrorStatus codes:
88 * null if full success
89 * positive if partial success
93 #define XpmColorError 1
95 #define XpmOpenFailed -1
96 #define XpmFileInvalid -2
97 #define XpmNoMemory -3
98 #define XpmColorFailed -4
101 char *name; /* Symbolic color name */
102 char *value; /* Color value */
103 Pixel pixel; /* Color pixel */
107 char *name; /* name of the extension */
108 unsigned int nlines; /* number of lines in this extension */
109 char **lines; /* pointer to the extension array of strings */
113 char *string; /* characters string */
114 char *symbolic; /* symbolic name */
115 char *m_color; /* monochrom default */
116 char *g4_color; /* 4 level grayscale default */
117 char *g_color; /* other level grayscale default */
118 char *c_color; /* color default */
122 unsigned int width; /* image width */
123 unsigned int height; /* image height */
124 unsigned int cpp; /* number of characters per pixel */
125 unsigned int ncolors; /* number of colors */
126 XpmColor *colorTable; /* list of related colors */
127 unsigned int *data; /* image data */
131 unsigned long valuemask; /* Specifies which attributes are defined */
132 char *hints_cmt; /* Comment of the hints section */
133 char *colors_cmt; /* Comment of the colors section */
134 char *pixels_cmt; /* Comment of the pixels section */
135 unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
136 unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
137 unsigned int nextensions; /* number of extensions */
138 XpmExtension *extensions; /* pointer to array of extensions */
141 typedef int (*XpmAllocColorFunc)(
142 Display* /* display */,
143 Colormap /* colormap */,
144 char* /* colorname */,
145 XColor* /* xcolor */,
149 typedef int (*XpmFreeColorsFunc)(
150 Display* /* display */,
151 Colormap /* colormap */,
158 unsigned long valuemask; /* Specifies which attributes are
161 Visual *visual; /* Specifies the visual to use */
162 Colormap colormap; /* Specifies the colormap to use */
163 unsigned int depth; /* Specifies the depth */
164 unsigned int width; /* Returns the width of the created
166 unsigned int height; /* Returns the height of the created
168 unsigned int x_hotspot; /* Returns the x hotspot's
170 unsigned int y_hotspot; /* Returns the y hotspot's
172 unsigned int cpp; /* Specifies the number of char per
174 Pixel *pixels; /* List of used color pixels */
175 unsigned int npixels; /* Number of used pixels */
176 XpmColorSymbol *colorsymbols; /* List of color symbols to override */
177 unsigned int numsymbols; /* Number of symbols */
178 char *rgb_fname; /* RGB text file name */
179 unsigned int nextensions; /* Number of extensions */
180 XpmExtension *extensions; /* List of extensions */
182 unsigned int ncolors; /* Number of colors */
183 XpmColor *colorTable; /* List of colors */
184 /* 3.2 backward compatibility code */
185 char *hints_cmt; /* Comment of the hints section */
186 char *colors_cmt; /* Comment of the colors section */
187 char *pixels_cmt; /* Comment of the pixels section */
189 unsigned int mask_pixel; /* Color table index of transparent
192 /* Color Allocation Directives */
193 Bool exactColors; /* Only use exact colors for visual */
194 unsigned int closeness; /* Allowable RGB deviation */
195 unsigned int red_closeness; /* Allowable red deviation */
196 unsigned int green_closeness; /* Allowable green deviation */
197 unsigned int blue_closeness; /* Allowable blue deviation */
198 int color_key; /* Use colors from this color set */
200 Pixel *alloc_pixels; /* Returns the list of alloc'ed color
202 int nalloc_pixels; /* Returns the number of alloc'ed
205 Bool alloc_close_colors; /* Specify whether close colors should
206 be allocated using XAllocColor
208 int bitmap_format; /* Specify the format of 1bit depth
209 images: ZPixmap or XYBitmap */
211 /* Color functions */
212 XpmAllocColorFunc alloc_color; /* Application color allocator */
213 XpmFreeColorsFunc free_colors; /* Application color de-allocator */
214 void *color_closure; /* Application private data to pass to
215 alloc_color and free_colors */
219 /* XpmAttributes value masks bits */
220 #define XpmVisual (1L<<0)
221 #define XpmColormap (1L<<1)
222 #define XpmDepth (1L<<2)
223 #define XpmSize (1L<<3) /* width & height */
224 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
225 #define XpmCharsPerPixel (1L<<5)
226 #define XpmColorSymbols (1L<<6)
227 #define XpmRgbFilename (1L<<7)
228 /* 3.2 backward compatibility code */
229 #define XpmInfos (1L<<8)
230 #define XpmReturnInfos XpmInfos
232 #define XpmReturnPixels (1L<<9)
233 #define XpmExtensions (1L<<10)
234 #define XpmReturnExtensions XpmExtensions
236 #define XpmExactColors (1L<<11)
237 #define XpmCloseness (1L<<12)
238 #define XpmRGBCloseness (1L<<13)
239 #define XpmColorKey (1L<<14)
241 #define XpmColorTable (1L<<15)
242 #define XpmReturnColorTable XpmColorTable
244 #define XpmReturnAllocPixels (1L<<16)
245 #define XpmAllocCloseColors (1L<<17)
246 #define XpmBitmapFormat (1L<<18)
248 #define XpmAllocColor (1L<<19)
249 #define XpmFreeColors (1L<<20)
250 #define XpmColorClosure (1L<<21)
253 /* XpmInfo value masks bits */
254 #define XpmComments XpmInfos
255 #define XpmReturnComments XpmComments
257 /* XpmAttributes mask_pixel value when there is no mask */
259 #define XpmUndefPixel 0x80000000
261 /* int is only 16 bit for MSW */
262 #define XpmUndefPixel 0x8000
266 * color keys for visual type, they must fit along with the number key of
267 * each related element in xpmColorKeys[] defined in XpmI.h
277 /* macros for forward declarations of functions with prototypes */
278 #define FUNC(f, t, p) extern t f p
279 #define LFUNC(f, t, p) static t f p
283 * functions declarations
288 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
289 /* Same for Amiga! */
291 #if !defined(FOR_MSW) && !defined(AMIGA)
292 FUNC(XpmCreatePixmapFromData, int, (Display *display,
295 Pixmap *pixmap_return,
296 Pixmap *shapemask_return,
297 XpmAttributes *attributes));
299 FUNC(XpmCreateDataFromPixmap, int, (Display *display,
303 XpmAttributes *attributes));
305 FUNC(XpmReadFileToPixmap, int, (Display *display,
308 Pixmap *pixmap_return,
309 Pixmap *shapemask_return,
310 XpmAttributes *attributes));
312 FUNC(XpmWriteFileFromPixmap, int, (Display *display,
316 XpmAttributes *attributes));
319 FUNC(XpmCreateImageFromData, int, (Display *display,
321 XImage **image_return,
322 XImage **shapemask_return,
323 XpmAttributes *attributes));
325 FUNC(XpmCreateDataFromImage, int, (Display *display,
329 XpmAttributes *attributes));
331 FUNC(XpmReadFileToImage, int, (Display *display,
333 XImage **image_return,
334 XImage **shapeimage_return,
335 XpmAttributes *attributes));
337 FUNC(XpmWriteFileFromImage, int, (Display *display,
341 XpmAttributes *attributes));
343 FUNC(XpmCreateImageFromBuffer, int, (Display *display,
345 XImage **image_return,
346 XImage **shapemask_return,
347 XpmAttributes *attributes));
348 #if !defined(FOR_MSW) && !defined(AMIGA)
349 FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
352 Pixmap *pixmap_return,
353 Pixmap *shapemask_return,
354 XpmAttributes *attributes));
356 FUNC(XpmCreateBufferFromImage, int, (Display *display,
357 char **buffer_return,
360 XpmAttributes *attributes));
362 FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
363 char **buffer_return,
366 XpmAttributes *attributes));
368 FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
369 FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
371 FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
372 FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
374 FUNC(XpmAttributesSize, int, (void));
375 FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
376 FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
379 FUNC(XpmFreeXpmImage, void, (XpmImage *image));
380 FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
381 FUNC(XpmGetErrorString, char *, (int errcode));
382 FUNC(XpmLibraryVersion, int, (void));
384 /* XpmImage functions */
385 FUNC(XpmReadFileToXpmImage, int, (char *filename,
389 FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
392 #if !defined(FOR_MSW) && !defined(AMIGA)
393 FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
396 Pixmap *pixmap_return,
397 Pixmap *shapemask_return,
398 XpmAttributes *attributes));
400 FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
402 XImage **image_return,
403 XImage **shapeimage_return,
404 XpmAttributes *attributes));
406 FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
410 XpmAttributes *attributes));
411 #if !defined(FOR_MSW) && !defined(AMIGA)
412 FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
416 XpmAttributes *attributes));
418 FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
422 FUNC(XpmCreateXpmImageFromData, int, (char **data,
426 FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
430 FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
434 FUNC(XpmGetParseError, int, (char *filename,
436 int *charnum_return));
438 FUNC(XpmFree, void, (void *ptr));
442 /* backward compatibility */
444 /* for version 3.0c */
445 #define XpmPixmapColorError XpmColorError
446 #define XpmPixmapSuccess XpmSuccess
447 #define XpmPixmapOpenFailed XpmOpenFailed
448 #define XpmPixmapFileInvalid XpmFileInvalid
449 #define XpmPixmapNoMemory XpmNoMemory
450 #define XpmPixmapColorFailed XpmColorFailed
452 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
453 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
454 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
455 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
457 /* for version 3.0b */
458 #define PixmapColorError XpmColorError
459 #define PixmapSuccess XpmSuccess
460 #define PixmapOpenFailed XpmOpenFailed
461 #define PixmapFileInvalid XpmFileInvalid
462 #define PixmapNoMemory XpmNoMemory
463 #define PixmapColorFailed XpmColorFailed
465 #define ColorSymbol XpmColorSymbol
467 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
468 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
469 #define XWritePixmapFile(dpy, file, pix, mask, att) \
470 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
471 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
472 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
473 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
474 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
476 #endif /* XPM_NUMBERS */