]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
fix some shell typos
[~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         /* image data hosed */
79         GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
80         /* no mem to load image */
81         GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
82         /* bad option value passed to save routine */
83         GDK_PIXBUF_ERROR_BAD_OPTION_VALUE,
84         /* unsupported image type (sort of an ENOSYS) */
85         GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
86         /* unsupported operation (load, save) for image type */
87         GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
88         GDK_PIXBUF_ERROR_FAILED
89 } GdkPixbufError;
90
91 GQuark gdk_pixbuf_error_quark () G_GNUC_CONST;
92
93 \f
94
95 GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
96
97 /* Reference counting */
98
99 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
100 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
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
146 /* Read an inline pixbuf */
147 GdkPixbuf *gdk_pixbuf_new_from_inline   (const guchar *inline_pixbuf,
148                                          gboolean      copy_pixels,
149                                          int           length,
150                                          GError      **error);
151
152 /* Mutations */
153 void       gdk_pixbuf_fill              (GdkPixbuf    *pixbuf,
154                                          guint32       pixel);
155
156 /* Saving */
157
158 gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
159                                     const char *filename, 
160                                     const char *type, 
161                                     GError    **error,
162                                     ...);
163
164 gboolean gdk_pixbuf_savev          (GdkPixbuf  *pixbuf, 
165                                     const char *filename, 
166                                     const char *type,
167                                     char      **option_keys,
168                                     char      **option_values,
169                                     GError    **error);
170
171 /* Adding an alpha channel */
172 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
173                                  guchar r, guchar g, guchar b);
174
175 /* Copy an area of a pixbuf onto another one */
176 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
177                            int src_x, int src_y,
178                            int width, int height,
179                            GdkPixbuf *dest_pixbuf,
180                            int dest_x, int dest_y);
181
182 /* Brighten/darken and optionally make it pixelated-looking */
183 void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
184                                        GdkPixbuf       *dest,
185                                        gfloat           saturation,
186                                        gboolean         pixelate);
187
188 \f
189
190 /* Rendering to a drawable */
191 \f
192
193 /* Scaling */
194
195 /* Interpolation modes */
196 typedef enum {
197         GDK_INTERP_NEAREST,
198         GDK_INTERP_TILES,
199         GDK_INTERP_BILINEAR,
200         GDK_INTERP_HYPER
201 } GdkInterpType;
202
203 void gdk_pixbuf_scale           (const GdkPixbuf *src,
204                                  GdkPixbuf       *dest,
205                                  int              dest_x,
206                                  int              dest_y,
207                                  int              dest_width,
208                                  int              dest_height,
209                                  double           offset_x,
210                                  double           offset_y,
211                                  double           scale_x,
212                                  double           scale_y,
213                                  GdkInterpType    interp_type);
214 void gdk_pixbuf_composite       (const GdkPixbuf *src,
215                                  GdkPixbuf       *dest,
216                                  int              dest_x,
217                                  int              dest_y,
218                                  int              dest_width,
219                                  int              dest_height,
220                                  double           offset_x,
221                                  double           offset_y,
222                                  double           scale_x,
223                                  double           scale_y,
224                                  GdkInterpType    interp_type,
225                                  int              overall_alpha);
226 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
227                                  GdkPixbuf       *dest,
228                                  int              dest_x,
229                                  int              dest_y,
230                                  int              dest_width,
231                                  int              dest_height,
232                                  double           offset_x,
233                                  double           offset_y,
234                                  double           scale_x,
235                                  double           scale_y,
236                                  GdkInterpType    interp_type,
237                                  int              overall_alpha,
238                                  int              check_x,
239                                  int              check_y,
240                                  int              check_size,
241                                  guint32          color1,
242                                  guint32          color2);
243
244 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
245                                               int              dest_width,
246                                               int              dest_height,
247                                               GdkInterpType    interp_type);
248
249 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
250                                               int              dest_width,
251                                               int              dest_height,
252                                               GdkInterpType    interp_type,
253                                               int              overall_alpha,
254                                               int              check_size,
255                                               guint32          color1,
256                                               guint32          color2);
257
258 \f
259
260 /* Animation support */
261
262 GType               gdk_pixbuf_animation_get_type        (void) G_GNUC_CONST;
263
264 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename,
265                                                           GError            **error);
266
267 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
268 void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
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  
286 #include <gdk-pixbuf/gdk-pixbuf-loader.h>
287
288 \f
289
290 #ifdef __cplusplus
291 }
292 #endif
293
294 #endif