GraphicsP.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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: GraphicsP.h /main/4 1996/05/09 03:43:09 drk $ */
  24. #ifndef _DtGraphicsP_h
  25. #define _DtGraphicsP_h
  26. #include <stdio.h>
  27. #include <X11/Intrinsic.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /*
  32. * Input stream data structures
  33. */
  34. /* Stream source types */
  35. enum _DtGrStreamType { _DtGrNONE, _DtGrBUFFER, _DtGrFILE };
  36. /* Stream file data */
  37. typedef struct
  38. {
  39. FILE *fileptr;
  40. char *filename;
  41. char *uncompressed_filename;
  42. } _DtGrFile;
  43. /* Stream buffer data */
  44. typedef struct
  45. {
  46. const char *base;
  47. long size;
  48. char *current;
  49. char *end;
  50. } _DtGrBuffer;
  51. /* Stream data */
  52. typedef struct
  53. {
  54. enum _DtGrStreamType type;
  55. union
  56. {
  57. _DtGrFile file;
  58. _DtGrBuffer buffer;
  59. } source;
  60. } _DtGrStream;
  61. /*
  62. * Input stream function prototypes
  63. */
  64. /* Open a file stream */
  65. int _DtGrOpenFile(
  66. _DtGrStream *stream,
  67. char *path
  68. );
  69. /* Open a buffer stream */
  70. int _DtGrOpenBuffer(
  71. _DtGrStream *stream,
  72. const char *buffer,
  73. int buffer_size
  74. );
  75. /* Close a stream */
  76. int _DtGrCloseStream(
  77. _DtGrStream *stream
  78. );
  79. /* Reads data from a stream into a buffer */
  80. size_t _DtGrRead(
  81. void *buffer,
  82. size_t size,
  83. size_t num_items,
  84. _DtGrStream *stream
  85. );
  86. /* Sets the position of the next input operation on a stream */
  87. int _DtGrSeek(
  88. _DtGrStream *stream,
  89. long offset,
  90. int whence
  91. );
  92. /* Reads a character from a stream and advances the stream position */
  93. int _DtGrGetChar(
  94. _DtGrStream *stream
  95. );
  96. /* Reads a string from a stream and advances the stream position */
  97. char *_DtGrGetString(
  98. char *buffer,
  99. int num_bytes,
  100. _DtGrStream *stream
  101. );
  102. /*
  103. * Inline graphics data structures
  104. */
  105. enum _DtGrColorModel { _DtGrCOLOR, _DtGrGRAY_SCALE, _DtGrBITONAL };
  106. enum _DtGrLoadStatus { _DtGrSUCCESS, _DtGrCOLOR_REDUCE,_DtGrCONVERT_FAILURE,
  107. _DtGrOPEN_FAILED, _DtGrFILE_INVALID, _DtGrNO_MEMORY,
  108. _DtGrCOLOR_FAILED };
  109. /* Context structure used by image type converters */
  110. typedef struct {
  111. char *image_type;
  112. XPointer context;
  113. } _DtGrContext;
  114. typedef enum _DtGrLoadStatus (*_DtGrLoadProc)(
  115. _DtGrStream *stream,
  116. Screen *screen,
  117. int depth,
  118. Colormap colormap,
  119. Visual *visual,
  120. Pixel foreground,
  121. Pixel background,
  122. GC gc,
  123. enum _DtGrColorModel color_model,
  124. Boolean allow_reduced_colors,
  125. Dimension *in_out_width,
  126. Dimension *in_out_height,
  127. unsigned short media_resolution,
  128. Pixmap *ret_pixmap,
  129. Pixmap *ret_mask,
  130. Pixel **ret_colors,
  131. int *ret_num_colors,
  132. _DtGrContext *context);
  133. typedef void (*_DtGrDestroyContextProc)(
  134. _DtGrContext *context);
  135. /*
  136. * Inline graphics function prototypes
  137. */
  138. /* Loads an image into a pixmap */
  139. enum _DtGrLoadStatus _DtGrLoad(
  140. _DtGrStream *stream,
  141. char **image_type,
  142. Screen *screen,
  143. int depth,
  144. Colormap colormap,
  145. Visual *visual,
  146. Pixel foreground,
  147. Pixel background,
  148. GC gc,
  149. enum _DtGrColorModel color_model,
  150. Boolean allow_reduced_colors,
  151. Dimension *in_out_width,
  152. Dimension *in_out_height,
  153. unsigned short media_resolution,
  154. Pixmap *ret_pixmap,
  155. Pixmap *ret_mask,
  156. Pixel **ret_colors,
  157. int *ret_num_colors,
  158. _DtGrContext *context);
  159. /* Destroys a context */
  160. void _DtGrDestroyContext(
  161. _DtGrContext *context);
  162. /* Registers a converter for a graphic type */
  163. void _DtGrRegisterConverter(
  164. char *image_type,
  165. _DtGrLoadProc convert_proc,
  166. _DtGrDestroyContextProc destroy_context_proc,
  167. _DtGrLoadProc *current_convert_proc,
  168. _DtGrDestroyContextProc *current_destroy_proc);
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* _DtGraphicsP_h */
  173. /* DON'T ADD ANYTHING AFTER THIS #endif */