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.
25 /* $XFree86: xc/extras/Xpm/lib/xpm.h,v 1.2 2001/08/22 23:36:44 dawes Exp $ */
27 /*****************************************************************************\
33 * Developed by Arnaud Le Hors *
34 \*****************************************************************************/
37 * The code related to FOR_MSW has been added by
38 * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
42 * The code related to AMIGA has been added by
43 * Lorens Younes (d93-hyo@nada.kth.se) 4/96
50 * first some identification numbers:
51 * the version and revision numbers are determined with the following rule:
52 * SO Major number = LIB minor version number.
53 * SO Minor number = LIB sub-minor version number.
54 * e.g: Xpm version 3.2f
55 * we forget the 3 which is the format number, 2 gives 2, and f gives 6.
56 * thus we have XpmVersion = 2 and XpmRevision = 6
57 * which gives SOXPMLIBREV = 2.6
59 * Then the XpmIncludeVersion number is built from these numbers.
63 #define XpmRevision 11
64 #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
69 # define SYSV /* uses memcpy string.h etc. */
71 # include "simx.h" /* defines some X stuff using MSW types */
72 #define NEED_STRCASECMP /* at least for MSVC++ */
76 # else /* not AMIGA */
77 # include <X11/Xlib.h>
78 # include <X11/Xutil.h>
79 # endif /* not AMIGA */
82 /* let's define Pixel if it is not done yet */
83 #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
84 typedef unsigned long Pixel
; /* Index into colormap */
85 # define PIXEL_ALREADY_TYPEDEFED
88 /* Return ErrorStatus codes:
89 * null if full success
90 * positive if partial success
94 #define XpmColorError 1
96 #define XpmOpenFailed -1
97 #define XpmFileInvalid -2
98 #define XpmNoMemory -3
99 #define XpmColorFailed -4
102 char *name
; /* Symbolic color name */
103 char *value
; /* Color value */
104 Pixel pixel
; /* Color pixel */
108 char *name
; /* name of the extension */
109 unsigned int nlines
; /* number of lines in this extension */
110 char **lines
; /* pointer to the extension array of strings */
114 char *string
; /* characters string */
115 char *symbolic
; /* symbolic name */
116 char *m_color
; /* monochrom default */
117 char *g4_color
; /* 4 level grayscale default */
118 char *g_color
; /* other level grayscale default */
119 char *c_color
; /* color default */
123 unsigned int width
; /* image width */
124 unsigned int height
; /* image height */
125 unsigned int cpp
; /* number of characters per pixel */
126 unsigned int ncolors
; /* number of colors */
127 XpmColor
*colorTable
; /* list of related colors */
128 unsigned int *data
; /* image data */
132 unsigned long valuemask
; /* Specifies which attributes are defined */
133 char *hints_cmt
; /* Comment of the hints section */
134 char *colors_cmt
; /* Comment of the colors section */
135 char *pixels_cmt
; /* Comment of the pixels section */
136 unsigned int x_hotspot
; /* Returns the x hotspot's coordinate */
137 unsigned int y_hotspot
; /* Returns the y hotspot's coordinate */
138 unsigned int nextensions
; /* number of extensions */
139 XpmExtension
*extensions
; /* pointer to array of extensions */
142 typedef int (*XpmAllocColorFunc
)(
143 Display
* /* display */,
144 Colormap
/* colormap */,
145 char* /* colorname */,
146 XColor
* /* xcolor */,
150 typedef int (*XpmFreeColorsFunc
)(
151 Display
* /* display */,
152 Colormap
/* colormap */,
159 unsigned long valuemask
; /* Specifies which attributes are
162 Visual
*visual
; /* Specifies the visual to use */
163 Colormap colormap
; /* Specifies the colormap to use */
164 unsigned int depth
; /* Specifies the depth */
165 unsigned int width
; /* Returns the width of the created
167 unsigned int height
; /* Returns the height of the created
169 unsigned int x_hotspot
; /* Returns the x hotspot's
171 unsigned int y_hotspot
; /* Returns the y hotspot's
173 unsigned int cpp
; /* Specifies the number of char per
175 Pixel
*pixels
; /* List of used color pixels */
176 unsigned int npixels
; /* Number of used pixels */
177 XpmColorSymbol
*colorsymbols
; /* List of color symbols to override */
178 unsigned int numsymbols
; /* Number of symbols */
179 char *rgb_fname
; /* RGB text file name */
180 unsigned int nextensions
; /* Number of extensions */
181 XpmExtension
*extensions
; /* List of extensions */
183 unsigned int ncolors
; /* Number of colors */
184 XpmColor
*colorTable
; /* List of colors */
185 /* 3.2 backward compatibility code */
186 char *hints_cmt
; /* Comment of the hints section */
187 char *colors_cmt
; /* Comment of the colors section */
188 char *pixels_cmt
; /* Comment of the pixels section */
190 unsigned int mask_pixel
; /* Color table index of transparent
193 /* Color Allocation Directives */
194 Bool exactColors
; /* Only use exact colors for visual */
195 unsigned int closeness
; /* Allowable RGB deviation */
196 unsigned int red_closeness
; /* Allowable red deviation */
197 unsigned int green_closeness
; /* Allowable green deviation */
198 unsigned int blue_closeness
; /* Allowable blue deviation */
199 int color_key
; /* Use colors from this color set */
201 Pixel
*alloc_pixels
; /* Returns the list of alloc'ed color
203 int nalloc_pixels
; /* Returns the number of alloc'ed
206 Bool alloc_close_colors
; /* Specify whether close colors should
207 be allocated using XAllocColor
209 int bitmap_format
; /* Specify the format of 1bit depth
210 images: ZPixmap or XYBitmap */
212 /* Color functions */
213 XpmAllocColorFunc alloc_color
; /* Application color allocator */
214 XpmFreeColorsFunc free_colors
; /* Application color de-allocator */
215 void *color_closure
; /* Application private data to pass to
216 alloc_color and free_colors */
220 /* XpmAttributes value masks bits */
221 #define XpmVisual (1L<<0)
222 #define XpmColormap (1L<<1)
223 #define XpmDepth (1L<<2)
224 #define XpmSize (1L<<3) /* width & height */
225 #define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
226 #define XpmCharsPerPixel (1L<<5)
227 #define XpmColorSymbols (1L<<6)
228 #define XpmRgbFilename (1L<<7)
229 /* 3.2 backward compatibility code */
230 #define XpmInfos (1L<<8)
231 #define XpmReturnInfos XpmInfos
233 #define XpmReturnPixels (1L<<9)
234 #define XpmExtensions (1L<<10)
235 #define XpmReturnExtensions XpmExtensions
237 #define XpmExactColors (1L<<11)
238 #define XpmCloseness (1L<<12)
239 #define XpmRGBCloseness (1L<<13)
240 #define XpmColorKey (1L<<14)
242 #define XpmColorTable (1L<<15)
243 #define XpmReturnColorTable XpmColorTable
245 #define XpmReturnAllocPixels (1L<<16)
246 #define XpmAllocCloseColors (1L<<17)
247 #define XpmBitmapFormat (1L<<18)
249 #define XpmAllocColor (1L<<19)
250 #define XpmFreeColors (1L<<20)
251 #define XpmColorClosure (1L<<21)
254 /* XpmInfo value masks bits */
255 #define XpmComments XpmInfos
256 #define XpmReturnComments XpmComments
258 /* XpmAttributes mask_pixel value when there is no mask */
260 #define XpmUndefPixel 0x80000000
262 /* int is only 16 bit for MSW */
263 #define XpmUndefPixel 0x8000
267 * color keys for visual type, they must fit along with the number key of
268 * each related element in xpmColorKeys[] defined in XpmI.h
278 /* macros for forward declarations of functions with prototypes */
279 #define FUNC(f, t, p) extern t f p
280 #define LFUNC(f, t, p) static t f p
284 * functions declarations
289 /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
290 /* Same for Amiga! */
292 #if !defined(FOR_MSW) && !defined(AMIGA)
293 FUNC(XpmCreatePixmapFromData
, int, (Display
*display
,
296 Pixmap
*pixmap_return
,
297 Pixmap
*shapemask_return
,
298 XpmAttributes
*attributes
));
300 FUNC(XpmCreateDataFromPixmap
, int, (Display
*display
,
304 XpmAttributes
*attributes
));
306 FUNC(XpmReadFileToPixmap
, int, (Display
*display
,
309 Pixmap
*pixmap_return
,
310 Pixmap
*shapemask_return
,
311 XpmAttributes
*attributes
));
313 FUNC(XpmWriteFileFromPixmap
, int, (Display
*display
,
317 XpmAttributes
*attributes
));
320 FUNC(XpmCreateImageFromData
, int, (Display
*display
,
322 XImage
**image_return
,
323 XImage
**shapemask_return
,
324 XpmAttributes
*attributes
));
326 FUNC(XpmCreateDataFromImage
, int, (Display
*display
,
330 XpmAttributes
*attributes
));
332 FUNC(XpmReadFileToImage
, int, (Display
*display
,
334 XImage
**image_return
,
335 XImage
**shapeimage_return
,
336 XpmAttributes
*attributes
));
338 FUNC(XpmWriteFileFromImage
, int, (Display
*display
,
342 XpmAttributes
*attributes
));
344 FUNC(XpmCreateImageFromBuffer
, int, (Display
*display
,
346 XImage
**image_return
,
347 XImage
**shapemask_return
,
348 XpmAttributes
*attributes
));
349 #if !defined(FOR_MSW) && !defined(AMIGA)
350 FUNC(XpmCreatePixmapFromBuffer
, int, (Display
*display
,
353 Pixmap
*pixmap_return
,
354 Pixmap
*shapemask_return
,
355 XpmAttributes
*attributes
));
357 FUNC(XpmCreateBufferFromImage
, int, (Display
*display
,
358 char **buffer_return
,
361 XpmAttributes
*attributes
));
363 FUNC(XpmCreateBufferFromPixmap
, int, (Display
*display
,
364 char **buffer_return
,
367 XpmAttributes
*attributes
));
369 FUNC(XpmReadFileToBuffer
, int, (char *filename
, char **buffer_return
));
370 FUNC(XpmWriteFileFromBuffer
, int, (char *filename
, char *buffer
));
372 FUNC(XpmReadFileToData
, int, (char *filename
, char ***data_return
));
373 FUNC(XpmWriteFileFromData
, int, (char *filename
, char **data
));
375 FUNC(XpmAttributesSize
, int, (void));
376 FUNC(XpmFreeAttributes
, void, (XpmAttributes
*attributes
));
377 FUNC(XpmFreeExtensions
, void, (XpmExtension
*extensions
,
380 FUNC(XpmFreeXpmImage
, void, (XpmImage
*image
));
381 FUNC(XpmFreeXpmInfo
, void, (XpmInfo
*info
));
382 FUNC(XpmGetErrorString
, char *, (int errcode
));
383 FUNC(XpmLibraryVersion
, int, (void));
385 /* XpmImage functions */
386 FUNC(XpmReadFileToXpmImage
, int, (char *filename
,
390 FUNC(XpmWriteFileFromXpmImage
, int, (char *filename
,
393 #if !defined(FOR_MSW) && !defined(AMIGA)
394 FUNC(XpmCreatePixmapFromXpmImage
, int, (Display
*display
,
397 Pixmap
*pixmap_return
,
398 Pixmap
*shapemask_return
,
399 XpmAttributes
*attributes
));
401 FUNC(XpmCreateImageFromXpmImage
, int, (Display
*display
,
403 XImage
**image_return
,
404 XImage
**shapeimage_return
,
405 XpmAttributes
*attributes
));
407 FUNC(XpmCreateXpmImageFromImage
, int, (Display
*display
,
411 XpmAttributes
*attributes
));
412 #if !defined(FOR_MSW) && !defined(AMIGA)
413 FUNC(XpmCreateXpmImageFromPixmap
, int, (Display
*display
,
417 XpmAttributes
*attributes
));
419 FUNC(XpmCreateDataFromXpmImage
, int, (char ***data_return
,
423 FUNC(XpmCreateXpmImageFromData
, int, (char **data
,
427 FUNC(XpmCreateXpmImageFromBuffer
, int, (char *buffer
,
431 FUNC(XpmCreateBufferFromXpmImage
, int, (char **buffer_return
,
435 FUNC(XpmGetParseError
, int, (char *filename
,
437 int *charnum_return
));
439 FUNC(XpmFree
, void, (void *ptr
));
443 /* backward compatibility */
445 /* for version 3.0c */
446 #define XpmPixmapColorError XpmColorError
447 #define XpmPixmapSuccess XpmSuccess
448 #define XpmPixmapOpenFailed XpmOpenFailed
449 #define XpmPixmapFileInvalid XpmFileInvalid
450 #define XpmPixmapNoMemory XpmNoMemory
451 #define XpmPixmapColorFailed XpmColorFailed
453 #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
454 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
455 #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
456 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
458 /* for version 3.0b */
459 #define PixmapColorError XpmColorError
460 #define PixmapSuccess XpmSuccess
461 #define PixmapOpenFailed XpmOpenFailed
462 #define PixmapFileInvalid XpmFileInvalid
463 #define PixmapNoMemory XpmNoMemory
464 #define PixmapColorFailed XpmColorFailed
466 #define ColorSymbol XpmColorSymbol
468 #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
469 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
470 #define XWritePixmapFile(dpy, file, pix, mask, att) \
471 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
472 #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
473 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
474 #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
475 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
477 #endif /* XPM_NUMBERS */