3764
|
1 /*
|
|
2 * Copyright (C) 1989-95 GROUPE BULL
|
|
3 *
|
|
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:
|
|
10 *
|
|
11 * The above copyright notice and this permission notice shall be included in
|
|
12 * all copies or substantial portions of the Software.
|
|
13 *
|
|
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.
|
|
20 *
|
|
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.
|
|
24 */
|
|
25
|
|
26 /*****************************************************************************\
|
|
27 * xpm.h: *
|
|
28 * *
|
|
29 * XPM library *
|
|
30 * Include file *
|
|
31 * *
|
|
32 * Developed by Arnaud Le Hors *
|
|
33 \*****************************************************************************/
|
|
34
|
|
35 /*
|
|
36 * The code related to FOR_MSW has been added by
|
|
37 * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
|
38 */
|
|
39
|
|
40 /*
|
|
41 * The code related to AMIGA has been added by
|
|
42 * Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
|
43 */
|
|
44
|
|
45 #ifndef XPM_h
|
|
46 #define XPM_h
|
|
47
|
|
48 /*
|
|
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
|
|
57 *
|
|
58 * Then the XpmIncludeVersion number is built from these numbers.
|
|
59 */
|
|
60 #define XpmFormat 3
|
|
61 #define XpmVersion 4
|
|
62 #define XpmRevision 11
|
|
63 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
|
|
64
|
|
65 #ifndef XPM_NUMBERS
|
|
66
|
|
67 #ifdef FOR_MSW
|
|
68 # define SYSV /* uses memcpy string.h etc. */
|
|
69 # include <malloc.h>
|
|
70 # include "simx.h" /* defines some X stuff using MSW types */
|
|
71 #define NEED_STRCASECMP /* at least for MSVC++ */
|
|
72 #else /* FOR_MSW */
|
|
73 # ifdef AMIGA
|
|
74 # include "amigax.h"
|
|
75 # else /* not AMIGA */
|
|
76 # include <X11/Xlib.h>
|
|
77 # include <X11/Xutil.h>
|
|
78 # endif /* not AMIGA */
|
|
79 #endif /* FOR_MSW */
|
|
80
|
|
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
|
|
85 #endif
|
|
86
|
|
87 /* make sure we know whether function prototypes are needed or not */
|
|
88 #ifndef NeedFunctionPrototypes
|
|
89 # if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
|
|
90 # define NeedFunctionPrototypes 1
|
|
91 # else
|
|
92 # define NeedFunctionPrototypes 0
|
|
93 # endif
|
|
94 #endif
|
|
95
|
|
96
|
|
97 /* Return ErrorStatus codes:
|
|
98 * null if full success
|
|
99 * positive if partial success
|
|
100 * negative if failure
|
|
101 */
|
|
102
|
|
103 #define XpmColorError 1
|
|
104 #define XpmSuccess 0
|
|
105 #define XpmOpenFailed -1
|
|
106 #define XpmFileInvalid -2
|
|
107 #define XpmNoMemory -3
|
|
108 #define XpmColorFailed -4
|
|
109
|
|
110 typedef struct {
|
|
111 char *name; /* Symbolic color name */
|
|
112 char *value; /* Color value */
|
|
113 Pixel pixel; /* Color pixel */
|
|
114 } XpmColorSymbol;
|
|
115
|
|
116 typedef struct {
|
|
117 char *name; /* name of the extension */
|
|
118 unsigned int nlines; /* number of lines in this extension */
|
|
119 char **lines; /* pointer to the extension array of strings */
|
|
120 } XpmExtension;
|
|
121
|
|
122 typedef struct {
|
|
123 char *string; /* characters string */
|
|
124 char *symbolic; /* symbolic name */
|
|
125 char *m_color; /* monochrom default */
|
|
126 char *g4_color; /* 4 level grayscale default */
|
|
127 char *g_color; /* other level grayscale default */
|
|
128 char *c_color; /* color default */
|
|
129 } XpmColor;
|
|
130
|
|
131 typedef struct {
|
|
132 unsigned int width; /* image width */
|
|
133 unsigned int height; /* image height */
|
|
134 unsigned int cpp; /* number of characters per pixel */
|
|
135 unsigned int ncolors; /* number of colors */
|
|
136 XpmColor *colorTable; /* list of related colors */
|
|
137 unsigned int *data; /* image data */
|
|
138 } XpmImage;
|
|
139
|
|
140 typedef struct {
|
|
141 unsigned long valuemask; /* Specifies which attributes are defined */
|
|
142 char *hints_cmt; /* Comment of the hints section */
|
|
143 char *colors_cmt; /* Comment of the colors section */
|
|
144 char *pixels_cmt; /* Comment of the pixels section */
|
|
145 unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
|
|
146 unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
|
|
147 unsigned int nextensions; /* number of extensions */
|
|
148 XpmExtension *extensions; /* pointer to array of extensions */
|
|
149 } XpmInfo;
|
|
150
|
|
151 typedef int (*XpmAllocColorFunc)(
|
|
152 #if NeedFunctionPrototypes
|
|
153 Display* /* display */,
|
|
154 Colormap /* colormap */,
|
|
155 char* /* colorname */,
|
|
156 XColor* /* xcolor */,
|
|
157 void* /* closure */
|
|
158 #endif
|
|
159 );
|
|
160
|
|
161 typedef int (*XpmFreeColorsFunc)(
|
|
162 #if NeedFunctionPrototypes
|
|
163 Display* /* display */,
|
|
164 Colormap /* colormap */,
|
|
165 Pixel* /* pixels */,
|
|
166 int /* npixels */,
|
|
167 void* /* closure */
|
|
168 #endif
|
|
169 );
|
|
170
|
|
171 typedef struct {
|
|
172 unsigned long valuemask; /* Specifies which attributes are
|
|
173 defined */
|
|
174
|
|
175 Visual *visual; /* Specifies the visual to use */
|
|
176 Colormap colormap; /* Specifies the colormap to use */
|
|
177 unsigned int depth; /* Specifies the depth */
|
|
178 unsigned int width; /* Returns the width of the created
|
|
179 pixmap */
|
|
180 unsigned int height; /* Returns the height of the created
|
|
181 pixmap */
|
|
182 unsigned int x_hotspot; /* Returns the x hotspot's
|
|
183 coordinate */
|
|
184 unsigned int y_hotspot; /* Returns the y hotspot's
|
|
185 coordinate */
|
|
186 unsigned int cpp; /* Specifies the number of char per
|
|
187 pixel */
|
|
188 Pixel *pixels; /* List of used color pixels */
|
|
189 unsigned int npixels; /* Number of used pixels */
|
|
190 XpmColorSymbol *colorsymbols; /* List of color symbols to override */
|
|
191 unsigned int numsymbols; /* Number of symbols */
|
|
192 char *rgb_fname; /* RGB text file name */
|
|
193 unsigned int nextensions; /* Number of extensions */
|
|
194 XpmExtension *extensions; /* List of extensions */
|
|
195
|
|
196 unsigned int ncolors; /* Number of colors */
|
|
197 XpmColor *colorTable; /* List of colors */
|
|
198 /* 3.2 backward compatibility code */
|
|
199 char *hints_cmt; /* Comment of the hints section */
|
|
200 char *colors_cmt; /* Comment of the colors section */
|
|
201 char *pixels_cmt; /* Comment of the pixels section */
|
|
202 /* end 3.2 bc */
|
|
203 unsigned int mask_pixel; /* Color table index of transparent
|
|
204 color */
|
|
205
|
|
206 /* Color Allocation Directives */
|
|
207 Bool exactColors; /* Only use exact colors for visual */
|
|
208 unsigned int closeness; /* Allowable RGB deviation */
|
|
209 unsigned int red_closeness; /* Allowable red deviation */
|
|
210 unsigned int green_closeness; /* Allowable green deviation */
|
|
211 unsigned int blue_closeness; /* Allowable blue deviation */
|
|
212 int color_key; /* Use colors from this color set */
|
|
213
|
|
214 Pixel *alloc_pixels; /* Returns the list of alloc'ed color
|
|
215 pixels */
|
|
216 int nalloc_pixels; /* Returns the number of alloc'ed
|
|
217 color pixels */
|
|
218
|
|
219 Bool alloc_close_colors; /* Specify whether close colors should
|
|
220 be allocated using XAllocColor
|
|
221 or not */
|
|
222 int bitmap_format; /* Specify the format of 1bit depth
|
|
223 images: ZPixmap or XYBitmap */
|
|
224
|
|
225 /* Color functions */
|
|
226 XpmAllocColorFunc alloc_color; /* Application color allocator */
|
|
227 XpmFreeColorsFunc free_colors; /* Application color de-allocator */
|
|
228 void *color_closure; /* Application private data to pass to
|
|
229 alloc_color and free_colors */
|
|
230
|
|
231 } XpmAttributes;
|
|
232
|
|
233 /* XpmAttributes value masks bits */
|
|
234 #define XpmVisual (1L<<0)
|
|
235 #define XpmColormap (1L<<1)
|
|
236 #define XpmDepth (1L<<2)
|
|
237 #define XpmSize (1L<<3) /* width & height */
|
|
238 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
|
|
239 #define XpmCharsPerPixel (1L<<5)
|
|
240 #define XpmColorSymbols (1L<<6)
|
|
241 #define XpmRgbFilename (1L<<7)
|
|
242 /* 3.2 backward compatibility code */
|
|
243 #define XpmInfos (1L<<8)
|
|
244 #define XpmReturnInfos XpmInfos
|
|
245 /* end 3.2 bc */
|
|
246 #define XpmReturnPixels (1L<<9)
|
|
247 #define XpmExtensions (1L<<10)
|
|
248 #define XpmReturnExtensions XpmExtensions
|
|
249
|
|
250 #define XpmExactColors (1L<<11)
|
|
251 #define XpmCloseness (1L<<12)
|
|
252 #define XpmRGBCloseness (1L<<13)
|
|
253 #define XpmColorKey (1L<<14)
|
|
254
|
|
255 #define XpmColorTable (1L<<15)
|
|
256 #define XpmReturnColorTable XpmColorTable
|
|
257
|
|
258 #define XpmReturnAllocPixels (1L<<16)
|
|
259 #define XpmAllocCloseColors (1L<<17)
|
|
260 #define XpmBitmapFormat (1L<<18)
|
|
261
|
|
262 #define XpmAllocColor (1L<<19)
|
|
263 #define XpmFreeColors (1L<<20)
|
|
264 #define XpmColorClosure (1L<<21)
|
|
265
|
|
266
|
|
267 /* XpmInfo value masks bits */
|
|
268 #define XpmComments XpmInfos
|
|
269 #define XpmReturnComments XpmComments
|
|
270
|
|
271 /* XpmAttributes mask_pixel value when there is no mask */
|
|
272 #ifndef FOR_MSW
|
|
273 #define XpmUndefPixel 0x80000000
|
|
274 #else
|
|
275 /* int is only 16 bit for MSW */
|
|
276 #define XpmUndefPixel 0x8000
|
|
277 #endif
|
|
278
|
|
279 /*
|
|
280 * color keys for visual type, they must fit along with the number key of
|
|
281 * each related element in xpmColorKeys[] defined in XpmI.h
|
|
282 */
|
|
283 #define XPM_MONO 2
|
|
284 #define XPM_GREY4 3
|
|
285 #define XPM_GRAY4 3
|
|
286 #define XPM_GREY 4
|
|
287 #define XPM_GRAY 4
|
|
288 #define XPM_COLOR 5
|
|
289
|
|
290
|
|
291 /* macros for forward declarations of functions with prototypes */
|
|
292 #if NeedFunctionPrototypes
|
|
293 #define FUNC(f, t, p) extern t f p
|
|
294 #define LFUNC(f, t, p) static t f p
|
|
295 #else
|
|
296 #define FUNC(f, t, p) extern t f()
|
|
297 #define LFUNC(f, t, p) static t f()
|
|
298 #endif
|
|
299
|
|
300
|
|
301 /*
|
|
302 * functions declarations
|
|
303 */
|
|
304
|
|
305 #ifdef __cplusplus
|
|
306 extern "C" {
|
|
307 #endif
|
|
308
|
|
309 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
|
|
310 /* Same for Amiga! */
|
|
311
|
|
312 #if !defined(FOR_MSW) && !defined(AMIGA)
|
|
313 FUNC(XpmCreatePixmapFromData, int, (Display *display,
|
|
314 Drawable d,
|
|
315 char **data,
|
|
316 Pixmap *pixmap_return,
|
|
317 Pixmap *shapemask_return,
|
|
318 XpmAttributes *attributes));
|
|
319
|
|
320 FUNC(XpmCreateDataFromPixmap, int, (Display *display,
|
|
321 char ***data_return,
|
|
322 Pixmap pixmap,
|
|
323 Pixmap shapemask,
|
|
324 XpmAttributes *attributes));
|
|
325
|
|
326 FUNC(XpmReadFileToPixmap, int, (Display *display,
|
|
327 Drawable d,
|
|
328 char *filename,
|
|
329 Pixmap *pixmap_return,
|
|
330 Pixmap *shapemask_return,
|
|
331 XpmAttributes *attributes));
|
|
332
|
|
333 FUNC(XpmWriteFileFromPixmap, int, (Display *display,
|
|
334 char *filename,
|
|
335 Pixmap pixmap,
|
|
336 Pixmap shapemask,
|
|
337 XpmAttributes *attributes));
|
|
338 #endif
|
|
339
|
|
340 FUNC(XpmCreateImageFromData, int, (Display *display,
|
|
341 char **data,
|
|
342 XImage **image_return,
|
|
343 XImage **shapemask_return,
|
|
344 XpmAttributes *attributes));
|
|
345
|
|
346 FUNC(XpmCreateDataFromImage, int, (Display *display,
|
|
347 char ***data_return,
|
|
348 XImage *image,
|
|
349 XImage *shapeimage,
|
|
350 XpmAttributes *attributes));
|
|
351
|
|
352 FUNC(XpmReadFileToImage, int, (Display *display,
|
|
353 char *filename,
|
|
354 XImage **image_return,
|
|
355 XImage **shapeimage_return,
|
|
356 XpmAttributes *attributes));
|
|
357
|
|
358 FUNC(XpmWriteFileFromImage, int, (Display *display,
|
|
359 char *filename,
|
|
360 XImage *image,
|
|
361 XImage *shapeimage,
|
|
362 XpmAttributes *attributes));
|
|
363
|
|
364 FUNC(XpmCreateImageFromBuffer, int, (Display *display,
|
|
365 char *buffer,
|
|
366 XImage **image_return,
|
|
367 XImage **shapemask_return,
|
|
368 XpmAttributes *attributes));
|
|
369 #if !defined(FOR_MSW) && !defined(AMIGA)
|
|
370 FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
|
|
371 Drawable d,
|
|
372 char *buffer,
|
|
373 Pixmap *pixmap_return,
|
|
374 Pixmap *shapemask_return,
|
|
375 XpmAttributes *attributes));
|
|
376
|
|
377 FUNC(XpmCreateBufferFromImage, int, (Display *display,
|
|
378 char **buffer_return,
|
|
379 XImage *image,
|
|
380 XImage *shapeimage,
|
|
381 XpmAttributes *attributes));
|
|
382
|
|
383 FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
|
|
384 char **buffer_return,
|
|
385 Pixmap pixmap,
|
|
386 Pixmap shapemask,
|
|
387 XpmAttributes *attributes));
|
|
388 #endif
|
|
389 FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
|
|
390 FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
|
|
391
|
|
392 FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
|
|
393 FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
|
|
394
|
|
395 FUNC(XpmAttributesSize, int, ());
|
|
396 FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
|
|
397 FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
|
|
398 int nextensions));
|
|
399
|
|
400 FUNC(XpmFreeXpmImage, void, (XpmImage *image));
|
|
401 FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
|
|
402 FUNC(XpmGetErrorString, char *, (int errcode));
|
|
403 FUNC(XpmLibraryVersion, int, ());
|
|
404
|
|
405 /* XpmImage functions */
|
|
406 FUNC(XpmReadFileToXpmImage, int, (char *filename,
|
|
407 XpmImage *image,
|
|
408 XpmInfo *info));
|
|
409
|
|
410 FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
|
|
411 XpmImage *image,
|
|
412 XpmInfo *info));
|
|
413 #if !defined(FOR_MSW) && !defined(AMIGA)
|
|
414 FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
|
|
415 Drawable d,
|
|
416 XpmImage *image,
|
|
417 Pixmap *pixmap_return,
|
|
418 Pixmap *shapemask_return,
|
|
419 XpmAttributes *attributes));
|
|
420 #endif
|
|
421 FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
|
|
422 XpmImage *image,
|
|
423 XImage **image_return,
|
|
424 XImage **shapeimage_return,
|
|
425 XpmAttributes *attributes));
|
|
426
|
|
427 FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
|
|
428 XImage *image,
|
|
429 XImage *shapeimage,
|
|
430 XpmImage *xpmimage,
|
|
431 XpmAttributes *attributes));
|
|
432 #if !defined(FOR_MSW) && !defined(AMIGA)
|
|
433 FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
|
|
434 Pixmap pixmap,
|
|
435 Pixmap shapemask,
|
|
436 XpmImage *xpmimage,
|
|
437 XpmAttributes *attributes));
|
|
438 #endif
|
|
439 FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
|
|
440 XpmImage *image,
|
|
441 XpmInfo *info));
|
|
442
|
|
443 FUNC(XpmCreateXpmImageFromData, int, (char **data,
|
|
444 XpmImage *image,
|
|
445 XpmInfo *info));
|
|
446
|
|
447 FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
|
|
448 XpmImage *image,
|
|
449 XpmInfo *info));
|
|
450
|
|
451 FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
|
|
452 XpmImage *image,
|
|
453 XpmInfo *info));
|
|
454
|
|
455 FUNC(XpmGetParseError, int, (char *filename,
|
|
456 int *linenum_return,
|
|
457 int *charnum_return));
|
|
458
|
|
459 FUNC(XpmFree, void, (void *ptr));
|
|
460
|
|
461 #ifdef __cplusplus
|
|
462 } /* for C++ V2.0 */
|
|
463 #endif
|
|
464
|
|
465
|
|
466 /* backward compatibility */
|
|
467
|
|
468 /* for version 3.0c */
|
|
469 #define XpmPixmapColorError XpmColorError
|
|
470 #define XpmPixmapSuccess XpmSuccess
|
|
471 #define XpmPixmapOpenFailed XpmOpenFailed
|
|
472 #define XpmPixmapFileInvalid XpmFileInvalid
|
|
473 #define XpmPixmapNoMemory XpmNoMemory
|
|
474 #define XpmPixmapColorFailed XpmColorFailed
|
|
475
|
|
476 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
|
|
477 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
|
|
478 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
|
|
479 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
|
|
480
|
|
481 /* for version 3.0b */
|
|
482 #define PixmapColorError XpmColorError
|
|
483 #define PixmapSuccess XpmSuccess
|
|
484 #define PixmapOpenFailed XpmOpenFailed
|
|
485 #define PixmapFileInvalid XpmFileInvalid
|
|
486 #define PixmapNoMemory XpmNoMemory
|
|
487 #define PixmapColorFailed XpmColorFailed
|
|
488
|
|
489 #define ColorSymbol XpmColorSymbol
|
|
490
|
|
491 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
|
|
492 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
|
|
493 #define XWritePixmapFile(dpy, file, pix, mask, att) \
|
|
494 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
|
|
495 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
|
|
496 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
|
|
497 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
|
|
498 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
|
|
499
|
|
500 #endif /* XPM_NUMBERS */
|
|
501 #endif
|