]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
Convert GdkPixbuf to GObject, leaving it opaque (i.e. derivation is not
[~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 Library 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  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library 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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <glib.h>
34 #include <gdk-pixbuf/gdk-pixbuf-features.h>
35 #include <gobject/gobject.h>
36
37 \f
38
39 /* Color spaces; right now only RGB is supported */
40 typedef enum {
41         GDK_COLORSPACE_RGB
42 } GdkColorspace;
43
44 /* All of these are opaque structures */
45 typedef struct _GdkPixbuf GdkPixbuf;
46 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
47 typedef struct _GdkPixbufFrame GdkPixbufFrame;
48
49 #define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
50 #define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
51 #define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
52
53 #define GDK_TYPE_PIXBUF_ANIMATION              (gdk_pixbuf_animation_get_type ())
54 #define GDK_PIXBUF_ANIMATION(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
55 #define GDK_IS_PIXBUF_ANIMATION(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
56
57
58 /* Handler that must free the pixel array */
59 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
60
61 \f
62
63 GType gdk_pixbuf_get_type (void);
64
65 /* Reference counting */
66
67 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
68 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
69
70 /* GdkPixbuf accessors */
71
72 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
73 int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
74 gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
75 int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
76 guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
77 int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
78 int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
79 int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
80
81 \f
82
83 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
84 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
85                            int width, int height);
86
87 /* Copy a pixbuf */
88
89 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
90
91 /* Simple loading */
92
93 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
94
95 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
96                                      GdkColorspace colorspace,
97                                      gboolean has_alpha,
98                                      int bits_per_sample,
99                                      int width, int height,
100                                      int rowstride,
101                                      GdkPixbufDestroyNotify destroy_fn,
102                                      gpointer destroy_fn_data);
103
104 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
105
106 /* Adding an alpha channel */
107 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
108                                  guchar r, guchar g, guchar b);
109
110 /* Copy an area of a pixbuf onto another one */
111 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
112                            int src_x, int src_y,
113                            int width, int height,
114                            GdkPixbuf *dest_pixbuf,
115                            int dest_x, int dest_y);
116
117 \f
118
119 /* Rendering to a drawable */
120 \f
121
122 /* Scaling */
123
124 /* Interpolation modes */
125 typedef enum {
126         GDK_INTERP_NEAREST,
127         GDK_INTERP_TILES,
128         GDK_INTERP_BILINEAR,
129         GDK_INTERP_HYPER
130 } GdkInterpType;
131
132 void gdk_pixbuf_scale           (const GdkPixbuf *src,
133                                  GdkPixbuf       *dest,
134                                  int              dest_x,
135                                  int              dest_y,
136                                  int              dest_width,
137                                  int              dest_height,
138                                  double           offset_x,
139                                  double           offset_y,
140                                  double           scale_x,
141                                  double           scale_y,
142                                  GdkInterpType    interp_type);
143 void gdk_pixbuf_composite       (const GdkPixbuf *src,
144                                  GdkPixbuf       *dest,
145                                  int              dest_x,
146                                  int              dest_y,
147                                  int              dest_width,
148                                  int              dest_height,
149                                  double           offset_x,
150                                  double           offset_y,
151                                  double           scale_x,
152                                  double           scale_y,
153                                  GdkInterpType    interp_type,
154                                  int              overall_alpha);
155 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
156                                  GdkPixbuf       *dest,
157                                  int              dest_x,
158                                  int              dest_y,
159                                  int              dest_width,
160                                  int              dest_height,
161                                  double           offset_x,
162                                  double           offset_y,
163                                  double           scale_x,
164                                  double           scale_y,
165                                  GdkInterpType    interp_type,
166                                  int              overall_alpha,
167                                  int              check_x,
168                                  int              check_y,
169                                  int              check_size,
170                                  guint32          color1,
171                                  guint32          color2);
172
173 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
174                                               int              dest_width,
175                                               int              dest_height,
176                                               GdkInterpType    interp_type);
177
178 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
179                                               int              dest_width,
180                                               int              dest_height,
181                                               GdkInterpType    interp_type,
182                                               int              overall_alpha,
183                                               int              check_size,
184                                               guint32          color1,
185                                               guint32          color2);
186
187 \f
188
189 /* Animation support */
190
191 /* GIF-like animation overlay modes for frames */
192 typedef enum {
193         GDK_PIXBUF_FRAME_RETAIN,
194         GDK_PIXBUF_FRAME_DISPOSE,
195         GDK_PIXBUF_FRAME_REVERT
196 } GdkPixbufFrameAction;
197
198 GType               gdk_pixbuf_animation_get_type        (void);
199
200 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename);
201
202 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
203 void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
204
205 int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
206 int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
207 GList              *gdk_pixbuf_animation_get_frames      (GdkPixbufAnimation *animation);
208 int                 gdk_pixbuf_animation_get_num_frames  (GdkPixbufAnimation *animation);
209
210 /* Frame accessors */
211
212 GdkPixbuf           *gdk_pixbuf_frame_get_pixbuf     (GdkPixbufFrame *frame);
213 int                  gdk_pixbuf_frame_get_x_offset   (GdkPixbufFrame *frame);
214 int                  gdk_pixbuf_frame_get_y_offset   (GdkPixbufFrame *frame);
215 int                  gdk_pixbuf_frame_get_delay_time (GdkPixbufFrame *frame);
216 GdkPixbufFrameAction gdk_pixbuf_frame_get_action     (GdkPixbufFrame *frame);
217
218
219 /* General (presently empty) initialization hooks, primarily for gnome-libs */
220 void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
221 void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
222 /* A more user-friendly init function */
223 void gdk_pixbuf_init     (void);
224
225 \f
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif