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