ilxpmP.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: ilxpmP.h /main/4 1995/10/23 16:03:34 rswiston $ */
  24. /* Copyright 1990,91 GROUPE BULL -- See licence conditions in file COPYRIGHT */
  25. /*****************************************************************************\
  26. * xpmP.h: *
  27. * *
  28. * XPM library *
  29. * Private Include file *
  30. * *
  31. * Developed by Arnaud Le Hors *
  32. \*****************************************************************************/
  33. #ifndef XPMP_h
  34. #define XPMP_h
  35. #ifdef Debug
  36. /* memory leak control tool */
  37. #include <mnemosyne.h>
  38. #endif
  39. /*
  40. #ifdef VMS
  41. #include "decw$include:Xlib.h"
  42. #include "decw$include:Intrinsic.h"
  43. #include "sys$library:stdio.h"
  44. #else
  45. #include <X11/Xlib.h>
  46. #include <X11/Intrinsic.h>
  47. #include <stdio.h>
  48. #endif
  49. */
  50. #include "ilxpm.h"
  51. #ifndef IL_H
  52. #include "il.h"
  53. #endif
  54. /* we keep the same codes as for Bitmap management */
  55. /*
  56. #ifndef _XUTIL_H_
  57. #ifdef VMS
  58. #include "decw$include:Xutil.h"
  59. #else
  60. #include <X11/Xutil.h>
  61. #endif
  62. #endif
  63. */
  64. typedef struct {
  65. unsigned int type;
  66. union {
  67. FILE *file;
  68. char **data;
  69. } stream;
  70. char *cptr;
  71. unsigned int line;
  72. int CommentLength;
  73. char Comment[BUFSIZ];
  74. char *Bcmt, *Ecmt, Bos, Eos;
  75. unsigned int InsideString; /* used during parsing: 0 or 1
  76. * whether we are inside or not */
  77. } xpmData;
  78. #define XPMARRAY 0
  79. #define XPMFILE 1
  80. #define XPMPIPE 2
  81. typedef unsigned char byte;
  82. #define EOL '\n'
  83. #define TAB '\t'
  84. #define SPC ' '
  85. typedef struct {
  86. char *type; /* key word */
  87. char *Bcmt; /* string begining comments */
  88. char *Ecmt; /* string ending comments */
  89. char Bos; /* character begining strings */
  90. char Eos; /* character ending strings */
  91. char *Strs; /* strings separator */
  92. char *Dec; /* data declaration string */
  93. char *Boa; /* string begining assignment */
  94. char *Eoa; /* string ending assignment */
  95. } xpmDataType;
  96. extern xpmDataType xpmDataTypes[];
  97. /*
  98. * rgb values and ascii names (from rgb text file) rgb values,
  99. * range of 0 -> 65535 color mnemonic of rgb value
  100. */
  101. typedef struct {
  102. int r, g, b;
  103. char *name;
  104. } xpmRgbName;
  105. /* Maximum number of rgb mnemonics allowed in rgb text file. */
  106. #define MAX_RGBNAMES 1024
  107. extern char *xpmColorKeys[];
  108. #define TRANSPARENT_COLOR "None" /* this must be a string! */
  109. /* number of xpmColorKeys */
  110. #define NKEYS 5
  111. /*
  112. * key numbers for visual type, they must fit along with the number key of
  113. * each corresponding element in xpmColorKeys[] defined in xpm.h
  114. */
  115. #define MONO 2
  116. #define GRAY4 3
  117. #define GRAY 4
  118. #define COLOR 5
  119. /* structure containing data related to an Xpm pixmap */
  120. typedef struct {
  121. char *name;
  122. unsigned int width;
  123. unsigned int height;
  124. unsigned int cpp;
  125. unsigned int ncolors;
  126. char ***colorTable;
  127. unsigned int *pixelindex;
  128. /* XColor *xcolors; */
  129. char **colorStrings;
  130. unsigned int mask_pixel; /* mask pixel's colorTable index */
  131. unsigned short *pPalette; /* color palette derived for xpm Image */
  132. short nPaletteColors; /* current entry count in palette */
  133. } xpmInternAttrib;
  134. #define UNDEF_PIXEL 0x80000000
  135. /* XPM private routines */
  136. FUNC(xpmCreateImage, int, (ilObject object,
  137. xpmInternAttrib * attrib,
  138. ilClientImage * image_return,
  139. ilClientImage * shapeimage_return,
  140. XpmAttributes * attributes));
  141. FUNC(xpmParseData, int, (xpmData * data,
  142. xpmInternAttrib * attrib_return,
  143. XpmAttributes * attributes));
  144. /*
  145. FUNC(xpmScanImage, int, (Display * display,
  146. XImage * image,
  147. XImage * shapeimage,
  148. XpmAttributes * attributes,
  149. xpmInternAttrib * attrib));
  150. FUNC(xpmVisualType, int, (Visual * visual));
  151. */
  152. FUNC(xpmFreeColorTable, int, (char ***colorTable, int ncolors));
  153. FUNC(xpmInitInternAttrib, int, (xpmInternAttrib * coedata));
  154. FUNC(xpmFreeInternAttrib, int, (xpmInternAttrib * coedata));
  155. FUNC(xpmSetAttributes, int, (xpmInternAttrib * attrib,
  156. XpmAttributes * attributes));
  157. FUNC(xpmGetAttributes, int, (XpmAttributes * attributes,
  158. xpmInternAttrib * attrib));
  159. /* I/O utility */
  160. FUNC(xpmNextString, int, (xpmData * mdata));
  161. FUNC(xpmNextUI, int, (xpmData * mdata, unsigned int *ui_return));
  162. FUNC(xpmGetC, int, (xpmData * mdata));
  163. FUNC(xpmUngetC, int, (int c, xpmData * mdata));
  164. FUNC(xpmNextWord, unsigned int, (xpmData * mdata, char *buf));
  165. FUNC(xpmGetCmt, int, (xpmData * mdata, char **cmt));
  166. FUNC(xpmReadFile, int, (char *filename, xpmData * mdata));
  167. FUNC(xpmWriteFile, int, (char *filename, xpmData * mdata));
  168. FUNC(xpmOpenArray, int, (char **data, xpmData * mdata));
  169. FUNC(XpmDataClose, int, (xpmData * mdata));
  170. /* RGB utility */
  171. /*
  172. FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName * rgbn));
  173. FUNC(xpmGetRgbName, char *, (xpmRgbName * rgbn, int rgbn_max,
  174. int red, int green, int blue));
  175. FUNC(xpmFreeRgbNames, void, (xpmRgbName * rgbn, int rgbn_max));
  176. FUNC(xpm_xynormalizeimagebits, int, (unsigned char *bp,
  177. XImage * img));
  178. FUNC(xpm_znormalizeimagebits, int, (unsigned char *bp,
  179. XImage * img));
  180. */
  181. /*
  182. * Macros
  183. *
  184. * The XYNORMALIZE macro determines whether XY format data requires
  185. * normalization and calls a routine to do so if needed. The logic in
  186. * this module is designed for LSBFirst byte and bit order, so
  187. * normalization is done as required to present the data in this order.
  188. *
  189. * The ZNORMALIZE macro performs byte and nibble order normalization if
  190. * required for Z format data.
  191. *
  192. * The XYINDEX macro computes the index to the starting byte (char) boundary
  193. * for a bitmap_unit containing a pixel with coordinates x and y for image
  194. * data in XY format.
  195. *
  196. * The ZINDEX* macros compute the index to the starting byte (char) boundary
  197. * for a pixel with coordinates x and y for image data in ZPixmap format.
  198. *
  199. */
  200. /*
  201. #define XYNORMALIZE(bp, img) \
  202. if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
  203. xpm_xynormalizeimagebits((unsigned char *)(bp), img)
  204. #define ZNORMALIZE(bp, img) \
  205. if (img->byte_order == MSBFirst) \
  206. xpm_znormalizeimagebits((unsigned char *)(bp), img)
  207. #define XYINDEX(x, y, img) \
  208. ((y) * img->bytes_per_line) + \
  209. (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
  210. #define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
  211. (((x) * img->bits_per_pixel) >> 3)
  212. #define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
  213. #define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
  214. #define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
  215. #define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
  216. */
  217. #if defined(__STDC__)
  218. #define Const const
  219. #else
  220. #define Const /**/
  221. #endif
  222. #endif