]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
Include glib-object.h, Add G_BEGIN_DECLS/END_DECLS to
[~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 G_BEGIN_DECLS
34
35 \f
36
37 /* Alpha compositing mode */
38 typedef enum
39 {
40         GDK_PIXBUF_ALPHA_BILEVEL,
41         GDK_PIXBUF_ALPHA_FULL
42 } GdkPixbufAlphaMode;
43
44 /* Color spaces; right now only RGB is supported.
45  * Note that these values are encoded in inline pixbufs
46  * as ints, so don't reorder them
47  */
48 typedef enum {
49         GDK_COLORSPACE_RGB
50 } GdkColorspace;
51
52 /* All of these are opaque structures */
53 typedef struct _GdkPixbuf GdkPixbuf;
54 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
55 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
56 typedef struct _GdkPixbufFrame GdkPixbufFrame;
57
58 #define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
59 #define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
60 #define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
61
62 #define GDK_TYPE_PIXBUF_ANIMATION              (gdk_pixbuf_animation_get_type ())
63 #define GDK_PIXBUF_ANIMATION(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
64 #define GDK_IS_PIXBUF_ANIMATION(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
65
66 #define GDK_TYPE_PIXBUF_ANIMATION_ITER              (gdk_pixbuf_animation_iter_get_type ())
67 #define GDK_PIXBUF_ANIMATION_ITER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
68 #define GDK_IS_PIXBUF_ANIMATION_ITER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
69
70 /* Handler that must free the pixel array */
71 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
72
73 #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
74
75 typedef enum {
76         /* image data hosed */
77         GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
78         /* no mem to load image */
79         GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
80         /* bad option passed to save routine */
81         GDK_PIXBUF_ERROR_BAD_OPTION,
82         /* unsupported image type (sort of an ENOSYS) */
83         GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
84         /* unsupported operation (load, save) for image type */
85         GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
86         GDK_PIXBUF_ERROR_FAILED
87 } GdkPixbufError;
88
89 GQuark gdk_pixbuf_error_quark (void) G_GNUC_CONST;
90
91 \f
92
93 GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
94
95 /* Reference counting */
96
97 #ifndef GDK_PIXBUF_DISABLE_DEPRECATED
98 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
99 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
100 #endif
101
102 /* GdkPixbuf accessors */
103
104 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
105 int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
106 gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
107 int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
108 guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
109 int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
110 int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
111 int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
112
113 \f
114
115 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
116 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
117                            int width, int height);
118
119 /* Copy a pixbuf */
120
121 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
122
123 /* Create a pixbuf which points to the pixels of another pixbuf */
124 GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
125                                      int        src_x,
126                                      int        src_y,
127                                      int        width,
128                                      int        height);
129
130 /* Simple loading */
131
132 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
133                                      GError    **error);
134
135 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
136                                      GdkColorspace colorspace,
137                                      gboolean has_alpha,
138                                      int bits_per_sample,
139                                      int width, int height,
140                                      int rowstride,
141                                      GdkPixbufDestroyNotify destroy_fn,
142                                      gpointer destroy_fn_data);
143
144 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
145 GdkPixbuf* gdk_pixbuf_new_from_inline   (gint          data_length,
146                                          const guint8 *data,
147                                          gboolean      copy_pixels,
148                                          GError      **error);
149        
150 /* Mutations */
151 void       gdk_pixbuf_fill              (GdkPixbuf    *pixbuf,
152                                          guint32       pixel);
153
154 /* Saving */
155
156 gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
157                                     const char *filename, 
158                                     const char *type, 
159                                     GError    **error,
160                                     ...);
161
162 gboolean gdk_pixbuf_savev          (GdkPixbuf  *pixbuf, 
163                                     const char *filename, 
164                                     const char *type,
165                                     char      **option_keys,
166                                     char      **option_values,
167                                     GError    **error);
168
169 /* Adding an alpha channel */
170 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
171                                  guchar r, guchar g, guchar b);
172
173 /* Copy an area of a pixbuf onto another one */
174 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
175                            int src_x, int src_y,
176                            int width, int height,
177                            GdkPixbuf *dest_pixbuf,
178                            int dest_x, int dest_y);
179
180 /* Brighten/darken and optionally make it pixelated-looking */
181 void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
182                                        GdkPixbuf       *dest,
183                                        gfloat           saturation,
184                                        gboolean         pixelate);
185
186 \f
187
188 /* Rendering to a drawable */
189 \f
190
191 /* Scaling */
192
193 /* Interpolation modes */
194 typedef enum {
195         GDK_INTERP_NEAREST,
196         GDK_INTERP_TILES,
197         GDK_INTERP_BILINEAR,
198         GDK_INTERP_HYPER
199 } GdkInterpType;
200
201 void gdk_pixbuf_scale           (const GdkPixbuf *src,
202                                  GdkPixbuf       *dest,
203                                  int              dest_x,
204                                  int              dest_y,
205                                  int              dest_width,
206                                  int              dest_height,
207                                  double           offset_x,
208                                  double           offset_y,
209                                  double           scale_x,
210                                  double           scale_y,
211                                  GdkInterpType    interp_type);
212 void gdk_pixbuf_composite       (const GdkPixbuf *src,
213                                  GdkPixbuf       *dest,
214                                  int              dest_x,
215                                  int              dest_y,
216                                  int              dest_width,
217                                  int              dest_height,
218                                  double           offset_x,
219                                  double           offset_y,
220                                  double           scale_x,
221                                  double           scale_y,
222                                  GdkInterpType    interp_type,
223                                  int              overall_alpha);
224 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
225                                  GdkPixbuf       *dest,
226                                  int              dest_x,
227                                  int              dest_y,
228                                  int              dest_width,
229                                  int              dest_height,
230                                  double           offset_x,
231                                  double           offset_y,
232                                  double           scale_x,
233                                  double           scale_y,
234                                  GdkInterpType    interp_type,
235                                  int              overall_alpha,
236                                  int              check_x,
237                                  int              check_y,
238                                  int              check_size,
239                                  guint32          color1,
240                                  guint32          color2);
241
242 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
243                                               int              dest_width,
244                                               int              dest_height,
245                                               GdkInterpType    interp_type);
246
247 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
248                                               int              dest_width,
249                                               int              dest_height,
250                                               GdkInterpType    interp_type,
251                                               int              overall_alpha,
252                                               int              check_size,
253                                               guint32          color1,
254                                               guint32          color2);
255
256 \f
257
258 /* Animation support */
259
260 GType               gdk_pixbuf_animation_get_type        (void) G_GNUC_CONST;
261
262 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename,
263                                                           GError            **error);
264
265 #ifndef GDK_PIXBUF_DISABLE_DEPRECATED
266 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
267 void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
268 #endif
269
270 int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
271 int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
272 gboolean            gdk_pixbuf_animation_is_static_image  (GdkPixbufAnimation *animation);
273 GdkPixbuf          *gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
274
275 GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter                        (GdkPixbufAnimation     *animation,
276                                                                               const GTimeVal         *start_time);
277 GType                   gdk_pixbuf_animation_iter_get_type                   (void) G_GNUC_CONST;
278 int                     gdk_pixbuf_animation_iter_get_delay_time             (GdkPixbufAnimationIter *iter);
279 GdkPixbuf              *gdk_pixbuf_animation_iter_get_pixbuf                 (GdkPixbufAnimationIter *iter);
280 gboolean                gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
281 gboolean                gdk_pixbuf_animation_iter_advance                    (GdkPixbufAnimationIter *iter,
282                                                                               const GTimeVal         *current_time);
283
284
285 \f
286
287 G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
288                                               const gchar *key);
289
290 \f
291  
292 G_END_DECLS
293
294 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
295 #include <gdk-pixbuf/gdk-pixbuf-enum-types.h>
296
297 \f
298
299 #endif