master
ブランチ master
ShaderPlayground / deps / xlibre / include / X11 / xpm.h
15.1 KB、452行 生 Blame 履歴
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#ifndef XPM_h
36#define XPM_h
37
38/*
39 * first some identification numbers:
40 * the version and revision numbers are determined with the following rule:
41 * SO Major number = LIB minor version number.
42 * SO Minor number = LIB sub-minor version number.
43 * e.g: Xpm version 3.2f
44 * we forget the 3 which is the format number, 2 gives 2, and f gives 6.
45 * thus we have XpmVersion = 2 and XpmRevision = 6
46 * which gives SOXPMLIBREV = 2.6
47 *
48 * Then the XpmIncludeVersion number is built from these numbers.
49 */
50#define XpmFormat 3
51#define XpmVersion 4
52#define XpmRevision 11
53#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
54
55#ifndef XPM_NUMBERS
56
57# include <X11/Xfuncproto.h>
58# include <X11/Xlib.h>
59# include <X11/Xutil.h>
60
61/* let's define Pixel if it is not done yet */
62#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
63typedef unsigned long Pixel; /* Index into colormap */
64# define PIXEL_ALREADY_TYPEDEFED
65#endif
66
67/* Return ErrorStatus codes:
68 * null if full success
69 * positive if partial success
70 * negative if failure
71 */
72
73#define XpmColorError 1
74#define XpmSuccess 0
75#define XpmOpenFailed -1
76#define XpmFileInvalid -2
77#define XpmNoMemory -3
78#define XpmColorFailed -4
79
80typedef struct {
81 char *name; /* Symbolic color name */
82 char *value; /* Color value */
83 Pixel pixel; /* Color pixel */
84} XpmColorSymbol;
85
86typedef struct {
87 char *name; /* name of the extension */
88 unsigned int nlines; /* number of lines in this extension */
89 char **lines; /* pointer to the extension array of strings */
90} XpmExtension;
91
92typedef struct {
93 char *string; /* characters string */
94 char *symbolic; /* symbolic name */
95 char *m_color; /* monochrom default */
96 char *g4_color; /* 4 level grayscale default */
97 char *g_color; /* other level grayscale default */
98 char *c_color; /* color default */
99} XpmColor;
100
101typedef struct {
102 unsigned int width; /* image width */
103 unsigned int height; /* image height */
104 unsigned int cpp; /* number of characters per pixel */
105 unsigned int ncolors; /* number of colors */
106 XpmColor *colorTable; /* list of related colors */
107 unsigned int *data; /* image data */
108} XpmImage;
109
110typedef struct {
111 unsigned long valuemask; /* Specifies which attributes are defined */
112 char *hints_cmt; /* Comment of the hints section */
113 char *colors_cmt; /* Comment of the colors section */
114 char *pixels_cmt; /* Comment of the pixels section */
115 unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
116 unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
117 unsigned int nextensions; /* number of extensions */
118 XpmExtension *extensions; /* pointer to array of extensions */
119} XpmInfo;
120
121typedef int (*XpmAllocColorFunc)(
122 Display* /* display */,
123 Colormap /* colormap */,
124 char* /* colorname */,
125 XColor* /* xcolor */,
126 void* /* closure */
127);
128
129typedef int (*XpmFreeColorsFunc)(
130 Display* /* display */,
131 Colormap /* colormap */,
132 Pixel* /* pixels */,
133 int /* npixels */,
134 void* /* closure */
135);
136
137typedef struct {
138 unsigned long valuemask; /* Specifies which attributes are
139 defined */
140
141 Visual *visual; /* Specifies the visual to use */
142 Colormap colormap; /* Specifies the colormap to use */
143 unsigned int depth; /* Specifies the depth */
144 unsigned int width; /* Returns the width of the created
145 pixmap */
146 unsigned int height; /* Returns the height of the created
147 pixmap */
148 unsigned int x_hotspot; /* Returns the x hotspot's
149 coordinate */
150 unsigned int y_hotspot; /* Returns the y hotspot's
151 coordinate */
152 unsigned int cpp; /* Specifies the number of char per
153 pixel */
154 Pixel *pixels; /* List of used color pixels */
155 unsigned int npixels; /* Number of used pixels */
156 XpmColorSymbol *colorsymbols; /* List of color symbols to override */
157 unsigned int numsymbols; /* Number of symbols */
158 char *rgb_fname; /* RGB text file name */
159 unsigned int nextensions; /* Number of extensions */
160 XpmExtension *extensions; /* List of extensions */
161
162 unsigned int ncolors; /* Number of colors */
163 XpmColor *colorTable; /* List of colors */
164/* 3.2 backward compatibility code */
165 char *hints_cmt; /* Comment of the hints section */
166 char *colors_cmt; /* Comment of the colors section */
167 char *pixels_cmt; /* Comment of the pixels section */
168/* end 3.2 bc */
169 unsigned int mask_pixel; /* Color table index of transparent
170 color */
171
172 /* Color Allocation Directives */
173 Bool exactColors; /* Only use exact colors for visual */
174 unsigned int closeness; /* Allowable RGB deviation */
175 unsigned int red_closeness; /* Allowable red deviation */
176 unsigned int green_closeness; /* Allowable green deviation */
177 unsigned int blue_closeness; /* Allowable blue deviation */
178 int color_key; /* Use colors from this color set */
179
180 Pixel *alloc_pixels; /* Returns the list of alloc'ed color
181 pixels */
182 int nalloc_pixels; /* Returns the number of alloc'ed
183 color pixels */
184
185 Bool alloc_close_colors; /* Specify whether close colors should
186 be allocated using XAllocColor
187 or not */
188 int bitmap_format; /* Specify the format of 1bit depth
189 images: ZPixmap or XYBitmap */
190
191 /* Color functions */
192 XpmAllocColorFunc alloc_color; /* Application color allocator */
193 XpmFreeColorsFunc free_colors; /* Application color de-allocator */
194 void *color_closure; /* Application private data to pass to
195 alloc_color and free_colors */
196
197} XpmAttributes;
198
199/* XpmAttributes value masks bits */
200#define XpmVisual (1L<<0)
201#define XpmColormap (1L<<1)
202#define XpmDepth (1L<<2)
203#define XpmSize (1L<<3) /* width & height */
204#define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
205#define XpmCharsPerPixel (1L<<5)
206#define XpmColorSymbols (1L<<6)
207#define XpmRgbFilename (1L<<7)
208/* 3.2 backward compatibility code */
209#define XpmInfos (1L<<8)
210#define XpmReturnInfos XpmInfos
211/* end 3.2 bc */
212#define XpmReturnPixels (1L<<9)
213#define XpmExtensions (1L<<10)
214#define XpmReturnExtensions XpmExtensions
215
216#define XpmExactColors (1L<<11)
217#define XpmCloseness (1L<<12)
218#define XpmRGBCloseness (1L<<13)
219#define XpmColorKey (1L<<14)
220
221#define XpmColorTable (1L<<15)
222#define XpmReturnColorTable XpmColorTable
223
224#define XpmReturnAllocPixels (1L<<16)
225#define XpmAllocCloseColors (1L<<17)
226#define XpmBitmapFormat (1L<<18)
227
228#define XpmAllocColor (1L<<19)
229#define XpmFreeColors (1L<<20)
230#define XpmColorClosure (1L<<21)
231
232
233/* XpmInfo value masks bits */
234#define XpmComments XpmInfos
235#define XpmReturnComments XpmComments
236
237/* XpmAttributes mask_pixel value when there is no mask */
238#define XpmUndefPixel 0x80000000
239
240/*
241 * color keys for visual type, they must fit along with the number key of
242 * each related element in xpmColorKeys[] defined in XpmI.h
243 */
244#define XPM_MONO 2
245#define XPM_GREY4 3
246#define XPM_GRAY4 3
247#define XPM_GREY 4
248#define XPM_GRAY 4
249#define XPM_COLOR 5
250
251
252/* macros for forward declarations of functions with prototypes */
253#ifndef _X_EXPORT
254# define _X_EXPORT
255# define _X_HIDDEN
256#endif
257#define FUNC(f, t, p) extern _X_EXPORT t f p
258#define HFUNC(f, t, p) extern _X_HIDDEN t f p
259#define LFUNC(f, t, p) static t f p
260
261
262/*
263 * functions declarations
264 */
265
266_XFUNCPROTOBEGIN
267
268 FUNC(XpmCreatePixmapFromData, int, (Display *display,
269 Drawable d,
270 char **data,
271 Pixmap *pixmap_return,
272 Pixmap *shapemask_return,
273 XpmAttributes *attributes));
274
275 FUNC(XpmCreateDataFromPixmap, int, (Display *display,
276 char ***data_return,
277 Pixmap pixmap,
278 Pixmap shapemask,
279 XpmAttributes *attributes));
280
281 FUNC(XpmReadFileToPixmap, int, (Display *display,
282 Drawable d,
283 const char *filename,
284 Pixmap *pixmap_return,
285 Pixmap *shapemask_return,
286 XpmAttributes *attributes));
287
288 FUNC(XpmWriteFileFromPixmap, int, (Display *display,
289 const char *filename,
290 Pixmap pixmap,
291 Pixmap shapemask,
292 XpmAttributes *attributes));
293
294 FUNC(XpmCreateImageFromData, int, (Display *display,
295 char **data,
296 XImage **image_return,
297 XImage **shapemask_return,
298 XpmAttributes *attributes));
299
300 FUNC(XpmCreateDataFromImage, int, (Display *display,
301 char ***data_return,
302 XImage *image,
303 XImage *shapeimage,
304 XpmAttributes *attributes));
305
306 FUNC(XpmReadFileToImage, int, (Display *display,
307 const char *filename,
308 XImage **image_return,
309 XImage **shapeimage_return,
310 XpmAttributes *attributes));
311
312 FUNC(XpmWriteFileFromImage, int, (Display *display,
313 const char *filename,
314 XImage *image,
315 XImage *shapeimage,
316 XpmAttributes *attributes));
317
318 FUNC(XpmCreateImageFromBuffer, int, (Display *display,
319 char *buffer,
320 XImage **image_return,
321 XImage **shapemask_return,
322 XpmAttributes *attributes));
323
324 FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
325 Drawable d,
326 char *buffer,
327 Pixmap *pixmap_return,
328 Pixmap *shapemask_return,
329 XpmAttributes *attributes));
330
331 FUNC(XpmCreateBufferFromImage, int, (Display *display,
332 char **buffer_return,
333 XImage *image,
334 XImage *shapeimage,
335 XpmAttributes *attributes));
336
337 FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
338 char **buffer_return,
339 Pixmap pixmap,
340 Pixmap shapemask,
341 XpmAttributes *attributes));
342
343 FUNC(XpmReadFileToBuffer, int, (const char *filename, char **buffer_return));
344 FUNC(XpmWriteFileFromBuffer, int, (const char *filename, char *buffer));
345
346 FUNC(XpmReadFileToData, int, (const char *filename, char ***data_return));
347 FUNC(XpmWriteFileFromData, int, (const char *filename, char **data));
348
349 FUNC(XpmAttributesSize, int, (void));
350 FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
351 FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
352 int nextensions));
353
354 FUNC(XpmFreeXpmImage, void, (XpmImage *image));
355 FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
356 FUNC(XpmGetErrorString, char *, (int errcode));
357 FUNC(XpmLibraryVersion, int, (void));
358
359 /* XpmImage functions */
360 FUNC(XpmReadFileToXpmImage, int, (const char *filename,
361 XpmImage *image,
362 XpmInfo *info));
363
364 FUNC(XpmWriteFileFromXpmImage, int, (const char *filename,
365 XpmImage *image,
366 XpmInfo *info));
367
368 FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
369 Drawable d,
370 XpmImage *image,
371 Pixmap *pixmap_return,
372 Pixmap *shapemask_return,
373 XpmAttributes *attributes));
374
375 FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
376 XpmImage *image,
377 XImage **image_return,
378 XImage **shapeimage_return,
379 XpmAttributes *attributes));
380
381 FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
382 XImage *image,
383 XImage *shapeimage,
384 XpmImage *xpmimage,
385 XpmAttributes *attributes));
386
387 FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
388 Pixmap pixmap,
389 Pixmap shapemask,
390 XpmImage *xpmimage,
391 XpmAttributes *attributes));
392
393 FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
394 XpmImage *image,
395 XpmInfo *info));
396
397 FUNC(XpmCreateXpmImageFromData, int, (char **data,
398 XpmImage *image,
399 XpmInfo *info));
400
401 FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
402 XpmImage *image,
403 XpmInfo *info));
404
405 FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
406 XpmImage *image,
407 XpmInfo *info));
408
409 FUNC(XpmGetParseError, int, (char *filename,
410 int *linenum_return,
411 int *charnum_return));
412
413 FUNC(XpmFree, void, (void *ptr));
414
415_XFUNCPROTOEND
416
417/* backward compatibility */
418
419/* for version 3.0c */
420#define XpmPixmapColorError XpmColorError
421#define XpmPixmapSuccess XpmSuccess
422#define XpmPixmapOpenFailed XpmOpenFailed
423#define XpmPixmapFileInvalid XpmFileInvalid
424#define XpmPixmapNoMemory XpmNoMemory
425#define XpmPixmapColorFailed XpmColorFailed
426
427#define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
428 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
429#define XpmWritePixmapFile(dpy, file, pix, mask, att) \
430 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
431
432/* for version 3.0b */
433#define PixmapColorError XpmColorError
434#define PixmapSuccess XpmSuccess
435#define PixmapOpenFailed XpmOpenFailed
436#define PixmapFileInvalid XpmFileInvalid
437#define PixmapNoMemory XpmNoMemory
438#define PixmapColorFailed XpmColorFailed
439
440#define ColorSymbol XpmColorSymbol
441
442#define XReadPixmapFile(dpy, d, file, pix, mask, att) \
443 XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
444#define XWritePixmapFile(dpy, file, pix, mask, att) \
445 XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
446#define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
447 XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
448#define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
449 XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
450
451#endif /* XPM_NUMBERS */
452#endif