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 | |
20 | #ifndef GDK_PIXBUF_DISABLE_DEPRECATED |
21 | #include <gdk-pixbuf/gdk-pixbuf.h> |
22 | |
23 | G_BEGIN_DECLS |
24 | |
25 | /** |
26 | * GDK_PIXBUF_MAGIC_NUMBER: |
27 | * |
28 | * Magic number for #GdkPixdata structures. |
29 | **/ |
30 | #define GDK_PIXBUF_MAGIC_NUMBER (0x47646b50) /* 'GdkP' */ |
31 | |
32 | /** |
33 | * GdkPixdataType: |
34 | * @GDK_PIXDATA_COLOR_TYPE_RGB: each pixel has red, green and blue samples. |
35 | * @GDK_PIXDATA_COLOR_TYPE_RGBA: each pixel has red, green and blue samples |
36 | * and an alpha value. |
37 | * @GDK_PIXDATA_COLOR_TYPE_MASK: mask for the colortype flags of the enum. |
38 | * @GDK_PIXDATA_SAMPLE_WIDTH_8: each sample has 8 bits. |
39 | * @GDK_PIXDATA_SAMPLE_WIDTH_MASK: mask for the sample width flags of the enum. |
40 | * @GDK_PIXDATA_ENCODING_RAW: the pixel data is in raw form. |
41 | * @GDK_PIXDATA_ENCODING_RLE: the pixel data is run-length encoded. Runs may |
42 | * be up to 127 bytes long; their length is stored in a single byte |
43 | * preceding the pixel data for the run. If a run is constant, its length |
44 | * byte has the high bit set and the pixel data consists of a single pixel |
45 | * which must be repeated. |
46 | * @GDK_PIXDATA_ENCODING_MASK: mask for the encoding flags of the enum. |
47 | * |
48 | * An enumeration containing three sets of flags for a #GdkPixdata struct: |
49 | * one for the used colorspace, one for the width of the samples and one |
50 | * for the encoding of the pixel data. |
51 | * |
52 | * Deprecated: 2.32 |
53 | **/ |
54 | typedef enum |
55 | { |
56 | /* colorspace + alpha */ |
57 | GDK_PIXDATA_COLOR_TYPE_RGB = 0x01, |
58 | GDK_PIXDATA_COLOR_TYPE_RGBA = 0x02, |
59 | GDK_PIXDATA_COLOR_TYPE_MASK = 0xff, |
60 | /* width, support 8bits only currently */ |
61 | GDK_PIXDATA_SAMPLE_WIDTH_8 = 0x01 << 16, |
62 | GDK_PIXDATA_SAMPLE_WIDTH_MASK = 0x0f << 16, |
63 | /* encoding */ |
64 | GDK_PIXDATA_ENCODING_RAW = 0x01 << 24, |
65 | GDK_PIXDATA_ENCODING_RLE = 0x02 << 24, |
66 | GDK_PIXDATA_ENCODING_MASK = 0x0f << 24 |
67 | } GdkPixdataType; |
68 | |
69 | typedef struct _GdkPixdata GdkPixdata; |
70 | struct _GdkPixdata |
71 | { |
72 | guint32 magic; /* GDK_PIXBUF_MAGIC_NUMBER */ |
73 | gint32 length; /* <1 to disable length checks, otherwise: |
74 | * GDK_PIXDATA_HEADER_LENGTH + pixel_data length |
75 | */ |
76 | guint32 pixdata_type; /* GdkPixdataType */ |
77 | guint32 rowstride; |
78 | guint32 width; |
79 | guint32 height; |
80 | guint8 *pixel_data; |
81 | }; |
82 | |
83 | /** |
84 | * GDK_PIXDATA_HEADER_LENGTH: |
85 | * |
86 | * The length of a #GdkPixdata structure without the @pixel_data pointer. |
87 | * |
88 | * Deprecated: 2.32 |
89 | **/ |
90 | #define (4 + 4 + 4 + 4 + 4 + 4) |
91 | |
92 | /* the returned stream is plain htonl of GdkPixdata members + pixel_data */ |
93 | GDK_PIXBUF_DEPRECATED_IN_2_32 |
94 | guint8* gdk_pixdata_serialize (const GdkPixdata *pixdata, |
95 | guint *stream_length_p); |
96 | GDK_PIXBUF_DEPRECATED_IN_2_32 |
97 | gboolean gdk_pixdata_deserialize (GdkPixdata *pixdata, |
98 | guint stream_length, |
99 | const guint8 *stream, |
100 | GError **error); |
101 | GDK_PIXBUF_DEPRECATED_IN_2_32 |
102 | gpointer gdk_pixdata_from_pixbuf (GdkPixdata *pixdata, |
103 | const GdkPixbuf *pixbuf, |
104 | gboolean use_rle); |
105 | GDK_PIXBUF_DEPRECATED_IN_2_32 |
106 | GdkPixbuf* gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata, |
107 | gboolean copy_pixels, |
108 | GError **error); |
109 | /** |
110 | * GdkPixdataDumpType: |
111 | * @GDK_PIXDATA_DUMP_PIXDATA_STREAM: Generate pixbuf data stream (a single |
112 | * string containing a serialized #GdkPixdata structure in network byte |
113 | * order). |
114 | * @GDK_PIXDATA_DUMP_PIXDATA_STRUCT: Generate #GdkPixdata structure (needs |
115 | * the #GdkPixdata structure definition from gdk-pixdata.h). |
116 | * @GDK_PIXDATA_DUMP_MACROS: Generate <function>*_ROWSTRIDE</function>, |
117 | * <function>*_WIDTH</function>, <function>*_HEIGHT</function>, |
118 | * <function>*_BYTES_PER_PIXEL</function> and |
119 | * <function>*_RLE_PIXEL_DATA</function> or <function>*_PIXEL_DATA</function> |
120 | * macro definitions for the image. |
121 | * @GDK_PIXDATA_DUMP_GTYPES: Generate GLib data types instead of |
122 | * standard C data types. |
123 | * @GDK_PIXDATA_DUMP_CTYPES: Generate standard C data types instead of |
124 | * GLib data types. |
125 | * @GDK_PIXDATA_DUMP_STATIC: Generate static symbols. |
126 | * @GDK_PIXDATA_DUMP_CONST: Generate const symbols. |
127 | * @GDK_PIXDATA_DUMP_RLE_DECODER: Provide a <function>*_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp)</function> |
128 | * macro definition to decode run-length encoded image data. |
129 | * |
130 | * An enumeration which is used by gdk_pixdata_to_csource() to |
131 | * determine the form of C source to be generated. The three values |
132 | * @GDK_PIXDATA_DUMP_PIXDATA_STREAM, @GDK_PIXDATA_DUMP_PIXDATA_STRUCT |
133 | * and @GDK_PIXDATA_DUMP_MACROS are mutually exclusive, as are |
134 | * @GDK_PIXBUF_DUMP_GTYPES and @GDK_PIXBUF_DUMP_CTYPES. The remaining |
135 | * elements are optional flags that can be freely added. |
136 | * |
137 | * Deprecated: 2.32 |
138 | **/ |
139 | typedef enum |
140 | { |
141 | /* type of source to save */ |
142 | GDK_PIXDATA_DUMP_PIXDATA_STREAM = 0, |
143 | GDK_PIXDATA_DUMP_PIXDATA_STRUCT = 1, |
144 | GDK_PIXDATA_DUMP_MACROS = 2, |
145 | /* type of variables to use */ |
146 | GDK_PIXDATA_DUMP_GTYPES = 0, |
147 | GDK_PIXDATA_DUMP_CTYPES = 1 << 8, |
148 | GDK_PIXDATA_DUMP_STATIC = 1 << 9, |
149 | GDK_PIXDATA_DUMP_CONST = 1 << 10, |
150 | /* save RLE decoder macro? */ |
151 | GDK_PIXDATA_DUMP_RLE_DECODER = 1 << 16 |
152 | } GdkPixdataDumpType; |
153 | |
154 | |
155 | GDK_PIXBUF_DEPRECATED_IN_2_32 |
156 | GString* gdk_pixdata_to_csource (GdkPixdata *pixdata, |
157 | const gchar *name, |
158 | GdkPixdataDumpType dump_type); |
159 | |
160 | |
161 | G_END_DECLS |
162 | |
163 | #endif /* GDK_PIXBUF_DISABLE_DEPRECATED */ |
164 | |
165 | #endif /* __GDK_PIXDATA_H__ */ |
166 | |