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