gdk-pixdata.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* GdkPixbuf library - GdkPixdata - functions for inlined pixbuf handling
  2. * Copyright (C) 1999, 2001 Tim Janik
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __GDK_PIXDATA_H__
  18. #define __GDK_PIXDATA_H__
  19. #ifndef GDK_PIXBUF_DISABLE_DEPRECATED
  20. #include <gdk-pixbuf/gdk-pixbuf.h>
  21. G_BEGIN_DECLS
  22. /**
  23. * GDK_PIXBUF_MAGIC_NUMBER:
  24. *
  25. * Magic number for #GdkPixdata structures.
  26. **/
  27. #define GDK_PIXBUF_MAGIC_NUMBER (0x47646b50) /* 'GdkP' */
  28. /**
  29. * GdkPixdataType:
  30. * @GDK_PIXDATA_COLOR_TYPE_RGB: each pixel has red, green and blue samples.
  31. * @GDK_PIXDATA_COLOR_TYPE_RGBA: each pixel has red, green and blue samples
  32. * and an alpha value.
  33. * @GDK_PIXDATA_COLOR_TYPE_MASK: mask for the colortype flags of the enum.
  34. * @GDK_PIXDATA_SAMPLE_WIDTH_8: each sample has 8 bits.
  35. * @GDK_PIXDATA_SAMPLE_WIDTH_MASK: mask for the sample width flags of the enum.
  36. * @GDK_PIXDATA_ENCODING_RAW: the pixel data is in raw form.
  37. * @GDK_PIXDATA_ENCODING_RLE: the pixel data is run-length encoded. Runs may
  38. * be up to 127 bytes long; their length is stored in a single byte
  39. * preceding the pixel data for the run. If a run is constant, its length
  40. * byte has the high bit set and the pixel data consists of a single pixel
  41. * which must be repeated.
  42. * @GDK_PIXDATA_ENCODING_MASK: mask for the encoding flags of the enum.
  43. *
  44. * An enumeration containing three sets of flags for a #GdkPixdata struct:
  45. * one for the used colorspace, one for the width of the samples and one
  46. * for the encoding of the pixel data.
  47. *
  48. * Deprecated: 2.32
  49. **/
  50. typedef enum
  51. {
  52. /* colorspace + alpha */
  53. GDK_PIXDATA_COLOR_TYPE_RGB = 0x01,
  54. GDK_PIXDATA_COLOR_TYPE_RGBA = 0x02,
  55. GDK_PIXDATA_COLOR_TYPE_MASK = 0xff,
  56. /* width, support 8bits only currently */
  57. GDK_PIXDATA_SAMPLE_WIDTH_8 = 0x01 << 16,
  58. GDK_PIXDATA_SAMPLE_WIDTH_MASK = 0x0f << 16,
  59. /* encoding */
  60. GDK_PIXDATA_ENCODING_RAW = 0x01 << 24,
  61. GDK_PIXDATA_ENCODING_RLE = 0x02 << 24,
  62. GDK_PIXDATA_ENCODING_MASK = 0x0f << 24
  63. } GdkPixdataType;
  64. typedef struct _GdkPixdata GdkPixdata;
  65. struct _GdkPixdata
  66. {
  67. guint32 magic; /* GDK_PIXBUF_MAGIC_NUMBER */
  68. gint32 length; /* <1 to disable length checks, otherwise:
  69. * GDK_PIXDATA_HEADER_LENGTH + pixel_data length
  70. */
  71. guint32 pixdata_type; /* GdkPixdataType */
  72. guint32 rowstride;
  73. guint32 width;
  74. guint32 height;
  75. guint8 *pixel_data;
  76. };
  77. /**
  78. * GDK_PIXDATA_HEADER_LENGTH:
  79. *
  80. * The length of a #GdkPixdata structure without the @pixel_data pointer.
  81. *
  82. * Deprecated: 2.32
  83. **/
  84. #define GDK_PIXDATA_HEADER_LENGTH (4 + 4 + 4 + 4 + 4 + 4)
  85. /* the returned stream is plain htonl of GdkPixdata members + pixel_data */
  86. GDK_PIXBUF_DEPRECATED_IN_2_32
  87. guint8* gdk_pixdata_serialize (const GdkPixdata *pixdata,
  88. guint *stream_length_p);
  89. GDK_PIXBUF_DEPRECATED_IN_2_32
  90. gboolean gdk_pixdata_deserialize (GdkPixdata *pixdata,
  91. guint stream_length,
  92. const guint8 *stream,
  93. GError **error);
  94. GDK_PIXBUF_DEPRECATED_IN_2_32
  95. gpointer gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
  96. const GdkPixbuf *pixbuf,
  97. gboolean use_rle);
  98. GDK_PIXBUF_DEPRECATED_IN_2_32
  99. GdkPixbuf* gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata,
  100. gboolean copy_pixels,
  101. GError **error);
  102. /**
  103. * GdkPixdataDumpType:
  104. * @GDK_PIXDATA_DUMP_PIXDATA_STREAM: Generate pixbuf data stream (a single
  105. * string containing a serialized #GdkPixdata structure in network byte
  106. * order).
  107. * @GDK_PIXDATA_DUMP_PIXDATA_STRUCT: Generate #GdkPixdata structure (needs
  108. * the #GdkPixdata structure definition from gdk-pixdata.h).
  109. * @GDK_PIXDATA_DUMP_MACROS: Generate <function>*_ROWSTRIDE</function>,
  110. * <function>*_WIDTH</function>, <function>*_HEIGHT</function>,
  111. * <function>*_BYTES_PER_PIXEL</function> and
  112. * <function>*_RLE_PIXEL_DATA</function> or <function>*_PIXEL_DATA</function>
  113. * macro definitions for the image.
  114. * @GDK_PIXDATA_DUMP_GTYPES: Generate GLib data types instead of
  115. * standard C data types.
  116. * @GDK_PIXDATA_DUMP_CTYPES: Generate standard C data types instead of
  117. * GLib data types.
  118. * @GDK_PIXDATA_DUMP_STATIC: Generate static symbols.
  119. * @GDK_PIXDATA_DUMP_CONST: Generate const symbols.
  120. * @GDK_PIXDATA_DUMP_RLE_DECODER: Provide a <function>*_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp)</function>
  121. * macro definition to decode run-length encoded image data.
  122. *
  123. * An enumeration which is used by gdk_pixdata_to_csource() to
  124. * determine the form of C source to be generated. The three values
  125. * @GDK_PIXDATA_DUMP_PIXDATA_STREAM, @GDK_PIXDATA_DUMP_PIXDATA_STRUCT
  126. * and @GDK_PIXDATA_DUMP_MACROS are mutually exclusive, as are
  127. * @GDK_PIXBUF_DUMP_GTYPES and @GDK_PIXBUF_DUMP_CTYPES. The remaining
  128. * elements are optional flags that can be freely added.
  129. *
  130. * Deprecated: 2.32
  131. **/
  132. typedef enum
  133. {
  134. /* type of source to save */
  135. GDK_PIXDATA_DUMP_PIXDATA_STREAM = 0,
  136. GDK_PIXDATA_DUMP_PIXDATA_STRUCT = 1,
  137. GDK_PIXDATA_DUMP_MACROS = 2,
  138. /* type of variables to use */
  139. GDK_PIXDATA_DUMP_GTYPES = 0,
  140. GDK_PIXDATA_DUMP_CTYPES = 1 << 8,
  141. GDK_PIXDATA_DUMP_STATIC = 1 << 9,
  142. GDK_PIXDATA_DUMP_CONST = 1 << 10,
  143. /* save RLE decoder macro? */
  144. GDK_PIXDATA_DUMP_RLE_DECODER = 1 << 16
  145. } GdkPixdataDumpType;
  146. GDK_PIXBUF_DEPRECATED_IN_2_32
  147. GString* gdk_pixdata_to_csource (GdkPixdata *pixdata,
  148. const gchar *name,
  149. GdkPixdataDumpType dump_type);
  150. G_END_DECLS
  151. #endif /* GDK_PIXBUF_DISABLE_DEPRECATED */
  152. #endif /* __GDK_PIXDATA_H__ */