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 /*****************************************************************************\
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
43 #if defined(_WINDOWS) || defined(__WXMSW__) || defined(WIN32)
48 * first some identification numbers:
49 * the following revision numbers is determined with the following rule:
50 * SO Major number = LIB minor version number.
51 * SO Minor number = LIB sub-minor version number.
52 * e.g: Xpm version 3.2f
53 * we forget the 3 which is the format number, 2 gives 2, and f gives 6.
54 * thus we have XpmVersion = 2 and XpmRevision = 6
55 * which gives SOXPMLIBREV = 2.6
57 * Then the XpmIncludeVersion number is built with the following rule:
58 * (XpmFormat*100 + XpmVersion)*100 + XpmRevision
64 #define XpmIncludeVersion 30402
69 #include "decw$include:Xlib.h"
70 #include "decw$include:Xutil.h"
73 #define SYSV /* uses memcpy string.h etc. */
75 #include "simx.h" /* defines some X stuff using MSW types */
77 #define NEED_STRCASECMP /* at least for MSVC++ */
81 #include <X11/Xutil.h>
82 #include <stdlib.h> /* HEDU */
86 /* let's define Pixel if it is not done yet */
87 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
88 typedef unsigned long Pixel
; /* Index into colormap */
89 #define PIXEL_ALREADY_TYPEDEFED
92 /* Return ErrorStatus codes:
93 * null if full success
94 * positive if partial success
98 #define XpmColorError 1
100 #define XpmOpenFailed -1
101 #define XpmFileInvalid -2
102 #define XpmNoMemory -3
103 #define XpmColorFailed -4
105 /* the following should help people wanting to use their own functions */
106 #define XpmFree(ptr) free(ptr)
109 char *name
; /* Symbolic color name */
110 char *value
; /* Color value */
111 Pixel pixel
; /* Color pixel */
115 char *name
; /* name of the extension */
116 unsigned int nlines
; /* number of lines in this extension */
117 char **lines
; /* pointer to the extension array of strings */
121 char *string
; /* characters string */
122 char *symbolic
; /* symbolic name */
123 char *m_color
; /* monochrom default */
124 char *g4_color
; /* 4 level grayscale default */
125 char *g_color
; /* other level grayscale default */
126 char *c_color
; /* color default */
130 unsigned int width
; /* image width */
131 unsigned int height
; /* image height */
132 unsigned int cpp
; /* number of characters per pixel */
133 unsigned int ncolors
; /* number of colors */
134 XpmColor
*colorTable
; /* list of related colors */
135 unsigned int *data
; /* image data */
139 unsigned long valuemask
; /* Specifies which attributes are defined */
140 char *hints_cmt
; /* Comment of the hints section */
141 char *colors_cmt
; /* Comment of the colors section */
142 char *pixels_cmt
; /* Comment of the pixels section */
143 unsigned int x_hotspot
; /* Returns the x hotspot's coordinate */
144 unsigned int y_hotspot
; /* Returns the y hotspot's coordinate */
145 unsigned int nextensions
; /* number of extensions */
146 XpmExtension
*extensions
; /* pointer to array of extensions */
150 unsigned long valuemask
; /* Specifies which attributes are
153 Visual
*visual
; /* Specifies the visual to use */
154 Colormap colormap
; /* Specifies the colormap to use */
155 unsigned int depth
; /* Specifies the depth */
156 unsigned int width
; /* Returns the width of the created
158 unsigned int height
; /* Returns the height of the created
160 unsigned int x_hotspot
; /* Returns the x hotspot's
162 unsigned int y_hotspot
; /* Returns the y hotspot's
164 unsigned int cpp
; /* Specifies the number of char per
166 Pixel
*pixels
; /* List of used color pixels */
167 unsigned int npixels
; /* Number of pixels */
168 XpmColorSymbol
*colorsymbols
; /* Array of color symbols to
170 unsigned int numsymbols
; /* Number of symbols */
171 char *rgb_fname
; /* RGB text file name */
172 unsigned int nextensions
; /* number of extensions */
173 XpmExtension
*extensions
; /* pointer to array of extensions */
175 unsigned int ncolors
; /* Number of colors */
176 XpmColor
*colorTable
; /* Color table pointer */
177 /* 3.2 backward compatibility code */
178 char *hints_cmt
; /* Comment of the hints section */
179 char *colors_cmt
; /* Comment of the colors section */
180 char *pixels_cmt
; /* Comment of the pixels section */
182 unsigned int mask_pixel
; /* Transparent pixel's color table
185 /* Color Allocation Directives */
186 unsigned int exactColors
; /* Only use exact colors for visual */
187 unsigned int closeness
; /* Allowable RGB deviation */
188 unsigned int red_closeness
; /* Allowable red deviation */
189 unsigned int green_closeness
; /* Allowable green deviation */
190 unsigned int blue_closeness
; /* Allowable blue deviation */
191 int color_key
; /* Use colors from this color set */
195 /* XpmAttributes value masks bits */
196 #define XpmVisual (1L<<0)
197 #define XpmColormap (1L<<1)
198 #define XpmDepth (1L<<2)
199 #define XpmSize (1L<<3) /* width & height */
200 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
201 #define XpmCharsPerPixel (1L<<5)
202 #define XpmColorSymbols (1L<<6)
203 #define XpmRgbFilename (1L<<7)
204 /* 3.2 backward compatibility code */
205 #define XpmInfos (1L<<8)
206 #define XpmReturnInfos XpmInfos
208 #define XpmReturnPixels (1L<<9)
209 #define XpmExtensions (1L<<10)
210 #define XpmReturnExtensions XpmExtensions
212 #define XpmExactColors (1L<<11)
213 #define XpmCloseness (1L<<12)
214 #define XpmRGBCloseness (1L<<13)
215 #define XpmColorKey (1L<<14)
217 #define XpmColorTable (1L<<15)
218 #define XpmReturnColorTable XpmColorTable
220 /* XpmInfo value masks bits */
221 #define XpmComments XpmInfos
222 #define XpmReturnComments XpmComments
224 /* XpmAttributes mask_pixel value when there is no mask */
226 #define XpmUndefPixel 0x80000000
228 /* int is only 16 bit for MSW */
229 #define XpmUndefPixel 0x8000
233 * color keys for visual type, they must fit along with the number key of
234 * each related element in xpmColorKeys[] defined in xpmP.h
245 * minimal portability layer between ansi and KR C
248 /* forward declaration of functions with prototypes */
250 #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
252 #define FUNC(f, t, p) extern t f p
253 #define LFUNC(f, t, p) static t f p
254 /* #define LFUNC(f, t, p) t f p */
256 #define FUNC(f, t, p) extern t f()
257 #define LFUNC(f, t, p) static t f()
258 /* #define LFUNC(f, t, p) t f() */
259 #endif /* end of K&R */
263 * functions declarations
270 /* For Microsoft C++ at any rate, the FUNC macro just doesn't work: it causes
271 * arguments to be corrupted espec. in XpmWriteFileFromXpmImage.
272 * So, define all prototypes explicitly.
276 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
278 int XpmCreateImageFromData(Display
*display
,
280 XImage
**image_return
,
281 XImage
**shapemask_return
,
282 XpmAttributes
*attributes
);
284 int XpmCreateDataFromImage(Display
*display
,
288 XpmAttributes
*attributes
);
290 int XpmReadFileToImage(Display
*display
,
292 XImage
**image_return
,
293 XImage
**shapeimage_return
,
294 XpmAttributes
*attributes
);
296 int XpmWriteFileFromImage(Display
*display
,
300 XpmAttributes
*attributes
);
302 int XpmCreateImageFromBuffer(Display
*display
,
304 XImage
**image_return
,
305 XImage
**shapemask_return
,
306 XpmAttributes
*attributes
);
308 int XpmReadFileToBuffer(char *filename
, char **buffer_return
);
309 int XpmWriteFileFromBuffer(char *filename
, char *buffer
);
311 int XpmReadFileToData(char *filename
, char ***data_return
);
312 int XpmWriteFileFromData(char *filename
, char **data
);
314 int XpmAttributesSize();
315 void XpmFreeAttributes(XpmAttributes
*attributes
);
316 void XpmFreeExtensions(XpmExtension
*extensions
,
319 void XpmFreeXpmImage(XpmImage
*image
);
320 void XpmFreeXpmInfo(XpmInfo
*info
);
321 char *XpmGetErrorString(int errcode
);
322 int XpmLibraryVersion();
324 /* XpmImage functions */
325 int XpmReadFileToXpmImage(char *filename
,
329 int XpmWriteFileFromXpmImage(char *filename
,
333 int XpmWriteFileFromXpmImage(char *filename
, XpmImage
*image
, XpmInfo
*info
);
335 int XpmCreateImageFromXpmImage(Display
*display
,
337 XImage
**image_return
,
338 XImage
**shapeimage_return
,
339 XpmAttributes
*attributes
);
341 int XpmCreateXpmImageFromImage(Display
*display
,
345 XpmAttributes
*attributes
);
346 int XpmCreateDataFromXpmImage(char ***data_return
,
350 int XpmCreateXpmImageFromData(char **data
,
354 int XpmCreateXpmImageFromBuffer(char *buffer
,
358 int XpmCreateBufferFromXpmImage(char **buffer_return
,
364 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
367 FUNC(XpmCreatePixmapFromData
, int, (Display
*display
,
370 Pixmap
*pixmap_return
,
371 Pixmap
*shapemask_return
,
372 XpmAttributes
*attributes
));
374 FUNC(XpmCreateDataFromPixmap
, int, (Display
*display
,
378 XpmAttributes
*attributes
));
380 FUNC(XpmReadFileToPixmap
, int, (Display
*display
,
383 Pixmap
*pixmap_return
,
384 Pixmap
*shapemask_return
,
385 XpmAttributes
*attributes
));
387 FUNC(XpmWriteFileFromPixmap
, int, (Display
*display
,
391 XpmAttributes
*attributes
));
392 #endif /* ndef FOR_MSW */
394 FUNC(XpmCreateImageFromData
, int, (Display
*display
,
396 XImage
**image_return
,
397 XImage
**shapemask_return
,
398 XpmAttributes
*attributes
));
400 FUNC(XpmCreateDataFromImage
, int, (Display
*display
,
404 XpmAttributes
*attributes
));
406 FUNC(XpmReadFileToImage
, int, (Display
*display
,
408 XImage
**image_return
,
409 XImage
**shapeimage_return
,
410 XpmAttributes
*attributes
));
412 FUNC(XpmWriteFileFromImage
, int, (Display
*display
,
416 XpmAttributes
*attributes
));
418 FUNC(XpmCreateImageFromBuffer
, int, (Display
*display
,
420 XImage
**image_return
,
421 XImage
**shapemask_return
,
422 XpmAttributes
*attributes
));
424 FUNC(XpmCreatePixmapFromBuffer
, int, (Display
*display
,
427 Pixmap
*pixmap_return
,
428 Pixmap
*shapemask_return
,
429 XpmAttributes
*attributes
));
431 FUNC(XpmCreateBufferFromImage
, int, (Display
*display
,
432 char **buffer_return
,
435 XpmAttributes
*attributes
));
437 FUNC(XpmCreateBufferFromPixmap
, int, (Display
*display
,
438 char **buffer_return
,
441 XpmAttributes
*attributes
));
442 #endif /* ndef FOR_MSW */
443 FUNC(XpmReadFileToBuffer
, int, (char *filename
, char **buffer_return
));
444 FUNC(XpmWriteFileFromBuffer
, int, (char *filename
, char *buffer
));
446 FUNC(XpmReadFileToData
, int, (char *filename
, char ***data_return
));
447 FUNC(XpmWriteFileFromData
, int, (char *filename
, char **data
));
449 FUNC(XpmAttributesSize
, int, ());
450 FUNC(XpmFreeAttributes
, void, (XpmAttributes
*attributes
));
451 FUNC(XpmFreeExtensions
, void, (XpmExtension
*extensions
,
454 FUNC(XpmFreeXpmImage
, void, (XpmImage
*image
));
455 FUNC(XpmFreeXpmInfo
, void, (XpmInfo
*info
));
456 FUNC(XpmGetErrorString
, char *, (int errcode
));
457 FUNC(XpmLibraryVersion
, int, ());
459 /* XpmImage functions */
460 FUNC(XpmReadFileToXpmImage
, int, (char *filename
,
464 FUNC(XpmWriteFileFromXpmImage
, int, (char *filename
,
468 FUNC(XpmWriteFileFromXpmImage
, int, (char *filename
, XpmImage
*image
, XpmInfo
*info
));
469 /* extern int XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info); */
472 FUNC(XpmCreatePixmapFromXpmImage
, int, (Display
*display
,
475 Pixmap
*pixmap_return
,
476 Pixmap
*shapemask_return
,
477 XpmAttributes
*attributes
));
479 FUNC(XpmCreateImageFromXpmImage
, int, (Display
*display
,
481 XImage
**image_return
,
482 XImage
**shapeimage_return
,
483 XpmAttributes
*attributes
));
485 FUNC(XpmCreateXpmImageFromImage
, int, (Display
*display
,
489 XpmAttributes
*attributes
));
491 FUNC(XpmCreateXpmImageFromPixmap
, int, (Display
*display
,
495 XpmAttributes
*attributes
));
497 FUNC(XpmCreateDataFromXpmImage
, int, (char ***data_return
,
501 FUNC(XpmCreateXpmImageFromData
, int, (char **data
,
505 FUNC(XpmCreateXpmImageFromBuffer
, int, (char *buffer
,
509 FUNC(XpmCreateBufferFromXpmImage
, int, (char **buffer_return
,
520 /* backward compatibility */
522 /* for version 3.0c */
523 #define XpmPixmapColorError XpmColorError
524 #define XpmPixmapSuccess XpmSuccess
525 #define XpmPixmapOpenFailed XpmOpenFailed
526 #define XpmPixmapFileInvalid XpmFileInvalid
527 #define XpmPixmapNoMemory XpmNoMemory
528 #define XpmPixmapColorFailed XpmColorFailed
530 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
531 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
532 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
533 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
535 /* for version 3.0b */
536 #define PixmapColorError XpmColorError
537 #define PixmapSuccess XpmSuccess
538 #define PixmapOpenFailed XpmOpenFailed
539 #define PixmapFileInvalid XpmFileInvalid
540 #define PixmapNoMemory XpmNoMemory
541 #define PixmapColorFailed XpmColorFailed
543 #define ColorSymbol XpmColorSymbol
545 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
546 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
547 #define XWritePixmapFile(dpy, file, pix, mask, att) \
548 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
549 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
550 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
551 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
552 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
554 #endif /* XPM_NUMBERS */