]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
use gdk_pixbuf_new_from_stream(). fixed up item factory so inlined pixbufs
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf.h
1 /* GdkPixbuf library - Main header file
2  *
3  * Copyright (C) 1999 The Free Software Foundation
4  *
5  * Authors: Mark Crichton <crichton@gimp.org>
6  *          Miguel de Icaza <miguel@gnu.org>
7  *          Federico Mena-Quintero <federico@gimp.org>
8  *          Havoc Pennington <hp@redhat.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */
25
26 #ifndef GDK_PIXBUF_H
27 #define GDK_PIXBUF_H
28
29 #include <glib.h>
30 #include <gdk-pixbuf/gdk-pixbuf-features.h>
31 #include <glib-object.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 \f
38
39 /* Alpha compositing mode */
40 typedef enum
41 {
42         GDK_PIXBUF_ALPHA_BILEVEL,
43         GDK_PIXBUF_ALPHA_FULL
44 } GdkPixbufAlphaMode;
45
46 /* Color spaces; right now only RGB is supported.
47  * Note that these values are encoded in inline pixbufs
48  * as ints, so don't reorder them
49  */
50 typedef enum {
51         GDK_COLORSPACE_RGB
52 } GdkColorspace;
53
54 /* All of these are opaque structures */
55 typedef struct _GdkPixbuf GdkPixbuf;
56 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
57 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
58 typedef struct _GdkPixbufFrame GdkPixbufFrame;
59
60 #define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
61 #define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
62 #define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
63
64 #define GDK_TYPE_PIXBUF_ANIMATION              (gdk_pixbuf_animation_get_type ())
65 #define GDK_PIXBUF_ANIMATION(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
66 #define GDK_IS_PIXBUF_ANIMATION(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
67
68 #define GDK_TYPE_PIXBUF_ANIMATION_ITER              (gdk_pixbuf_animation_iter_get_type ())
69 #define GDK_PIXBUF_ANIMATION_ITER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
70 #define GDK_IS_PIXBUF_ANIMATION_ITER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
71
72 /* Handler that must free the pixel array */
73 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
74
75 #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
76
77 typedef enum {
78         /* stream header corrupt */
79         GDK_PIXBUF_ERROR_HEADER_CORRUPT,
80         /* stream pixel data corrupt */
81         GDK_PIXBUF_ERROR_PIXEL_CORRUPT,
82         /* stream header corrupt */
83         GDK_PIXBUF_ERROR_UNKNOWN_FORMAT,
84         /* image data hosed */
85         GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
86         /* no mem to load image */
87         GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
88         /* bad option value passed to save routine */
89         GDK_PIXBUF_ERROR_BAD_OPTION_VALUE,
90         /* unsupported image type (sort of an ENOSYS) */
91         GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
92         /* unsupported operation (load, save) for image type */
93         GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
94         GDK_PIXBUF_ERROR_FAILED
95 } GdkPixbufError;
96
97 GQuark gdk_pixbuf_error_quark (void) G_GNUC_CONST;
98
99 \f
100
101 GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
102
103 /* Reference counting */
104
105 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
106 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
107
108 /* GdkPixbuf accessors */
109
110 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
111 int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
112 gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
113 int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
114 guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
115 int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
116 int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
117 int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
118
119 \f
120
121 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
122 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
123                            int width, int height);
124
125 /* Copy a pixbuf */
126
127 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
128
129 /* Create a pixbuf which points to the pixels of another pixbuf */
130 GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
131                                      int        src_x,
132                                      int        src_y,
133                                      int        width,
134                                      int        height);
135
136 /* Simple loading */
137
138 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
139                                      GError    **error);
140
141 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
142                                      GdkColorspace colorspace,
143                                      gboolean has_alpha,
144                                      int bits_per_sample,
145                                      int width, int height,
146                                      int rowstride,
147                                      GdkPixbufDestroyNotify destroy_fn,
148                                      gpointer destroy_fn_data);
149
150 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
151 GdkPixbuf* gdk_pixbuf_new_from_stream   (gint          stream_length,
152                                          const guint8 *stream,
153                                          gboolean      copy_pixels,
154                                          GError      **error);
155        
156 /* Mutations */
157 void       gdk_pixbuf_fill              (GdkPixbuf    *pixbuf,
158                                          guint32       pixel);
159
160 /* Saving */
161
162 gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
163                                     const char *filename, 
164                                     const char *type, 
165                                     GError    **error,
166                                     ...);
167
168 gboolean gdk_pixbuf_savev          (GdkPixbuf  *pixbuf, 
169                                     const char *filename, 
170                                     const char *type,
171                                     char      **option_keys,
172                                     char      **option_values,
173                                     GError    **error);
174
175 /* Adding an alpha channel */
176 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
177                                  guchar r, guchar g, guchar b);
178
179 /* Copy an area of a pixbuf onto another one */
180 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
181                            int src_x, int src_y,
182                            int width, int height,
183                            GdkPixbuf *dest_pixbuf,
184                            int dest_x, int dest_y);
185
186 /* Brighten/darken and optionally make it pixelated-looking */
187 void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
188                                        GdkPixbuf       *dest,
189                                        gfloat           saturation,
190                                        gboolean         pixelate);
191
192 \f
193
194 /* Rendering to a drawable */
195 \f
196
197 /* Scaling */
198
199 /* Interpolation modes */
200 typedef enum {
201         GDK_INTERP_NEAREST,
202         GDK_INTERP_TILES,
203         GDK_INTERP_BILINEAR,
204         GDK_INTERP_HYPER
205 } GdkInterpType;
206
207 void gdk_pixbuf_scale           (const GdkPixbuf *src,
208                                  GdkPixbuf       *dest,
209                                  int              dest_x,
210                                  int              dest_y,
211                                  int              dest_width,
212                                  int              dest_height,
213                                  double           offset_x,
214                                  double           offset_y,
215                                  double           scale_x,
216                                  double           scale_y,
217                                  GdkInterpType    interp_type);
218 void gdk_pixbuf_composite       (const GdkPixbuf *src,
219                                  GdkPixbuf       *dest,
220                                  int              dest_x,
221                                  int              dest_y,
222                                  int              dest_width,
223                                  int              dest_height,
224                                  double           offset_x,
225                                  double           offset_y,
226                                  double           scale_x,
227                                  double           scale_y,
228                                  GdkInterpType    interp_type,
229                                  int              overall_alpha);
230 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
231                                  GdkPixbuf       *dest,
232                                  int              dest_x,
233                                  int              dest_y,
234                                  int              dest_width,
235                                  int              dest_height,
236                                  double           offset_x,
237                                  double           offset_y,
238                                  double           scale_x,
239                                  double           scale_y,
240                                  GdkInterpType    interp_type,
241                                  int              overall_alpha,
242                                  int              check_x,
243                                  int              check_y,
244                                  int              check_size,
245                                  guint32          color1,
246                                  guint32          color2);
247
248 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
249                                               int              dest_width,
250                                               int              dest_height,
251                                               GdkInterpType    interp_type);
252
253 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
254                                               int              dest_width,
255                                               int              dest_height,
256                                               GdkInterpType    interp_type,
257                                               int              overall_alpha,
258                                               int              check_size,
259                                               guint32          color1,
260                                               guint32          color2);
261
262 \f
263
264 /* Animation support */
265
266 GType               gdk_pixbuf_animation_get_type        (void) G_GNUC_CONST;
267
268 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename,
269                                                           GError            **error);
270
271 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
272 void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
273
274 int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
275 int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
276 gboolean            gdk_pixbuf_animation_is_static_image  (GdkPixbufAnimation *animation);
277 GdkPixbuf          *gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
278
279 GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter                        (GdkPixbufAnimation     *animation,
280                                                                               const GTimeVal         *start_time);
281 GType                   gdk_pixbuf_animation_iter_get_type                   (void) G_GNUC_CONST;
282 int                     gdk_pixbuf_animation_iter_get_delay_time             (GdkPixbufAnimationIter *iter);
283 GdkPixbuf              *gdk_pixbuf_animation_iter_get_pixbuf                 (GdkPixbufAnimationIter *iter);
284 gboolean                gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
285 gboolean                gdk_pixbuf_animation_iter_advance                    (GdkPixbufAnimationIter *iter,
286                                                                               const GTimeVal         *current_time);
287
288
289  
290 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
291
292 \f
293
294 #ifdef __cplusplus
295 }
296 #endif
297
298 #endif