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