]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
Most of this patch is based on a patch by Havoc Pennington (hp@redhat.com)
[~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 #include <gdk/gdk.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <gdk-pixbuf/gdk-pixbuf-features.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 _GdkPixbufFrame GdkPixbufFrame;
47 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
48
49 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
50
51 \f
52
53 /* Reference counting */
54
55 GdkPixbuf *gdk_pixbuf_ref   (GdkPixbuf *pixbuf);
56 void       gdk_pixbuf_unref (GdkPixbuf *pixbuf);
57
58 /* GdkPixbuf accessors */
59
60 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
61 int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
62 gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
63 int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
64 guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
65 int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
66 int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
67 int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
68
69 \f
70
71 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
72 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
73                            int width, int height);
74
75 /* Copy a pixbuf */
76
77 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
78
79 /* Simple loading */
80
81 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
82
83 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
84                                      GdkColorspace colorspace,
85                                      gboolean has_alpha,
86                                      int bits_per_sample,
87                                      int width, int height,
88                                      int rowstride,
89                                      GdkPixbufDestroyNotify destroy_fn,
90                                      gpointer destroy_fn_data);
91
92 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
93
94 /* Adding an alpha channel */
95 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
96                                  guchar r, guchar g, guchar b);
97
98 /* Copy an area of a pixbuf onto another one */
99 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
100                            int src_x, int src_y,
101                            int width, int height,
102                            GdkPixbuf *dest_pixbuf,
103                            int dest_x, int dest_y);
104
105 \f
106
107 /* Rendering to a drawable */
108
109 /* Alpha compositing mode */
110 typedef enum {
111         GDK_PIXBUF_ALPHA_BILEVEL,
112         GDK_PIXBUF_ALPHA_FULL
113 } GdkPixbufAlphaMode;
114
115 void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
116                                         int src_x, int src_y,
117                                         int dest_x, int dest_y,
118                                         int width, int height,
119                                         int alpha_threshold);
120
121 void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
122                                     GdkDrawable *drawable, GdkGC *gc,
123                                     int src_x, int src_y,
124                                     int dest_x, int dest_y,
125                                     int width, int height,
126                                     GdkRgbDither dither,
127                                     int x_dither, int y_dither);
128
129 void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
130                                           int src_x, int src_y,
131                                           int dest_x, int dest_y,
132                                           int width, int height,
133                                           GdkPixbufAlphaMode alpha_mode,
134                                           int alpha_threshold,
135                                           GdkRgbDither dither,
136                                           int x_dither, int y_dither);
137
138 void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
139                                         GdkPixmap **pixmap_return, GdkBitmap **mask_return,
140                                         int alpha_threshold);
141
142 /* Fetching a region from a drawable */
143 GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
144                                          GdkDrawable *src, GdkColormap *cmap,
145                                          int src_x, int src_y,
146                                          int dest_x, int dest_y,
147                                          int width, int height);
148
149 \f
150
151 /* Scaling */
152
153 /* Interpolation modes */
154 typedef enum {
155         GDK_INTERP_NEAREST,
156         GDK_INTERP_TILES,
157         GDK_INTERP_BILINEAR,
158         GDK_INTERP_HYPER
159 } GdkInterpType;
160
161 void gdk_pixbuf_scale           (const GdkPixbuf *src,
162                                  GdkPixbuf       *dest,
163                                  int              dest_x,
164                                  int              dest_y,
165                                  int              dest_width,
166                                  int              dest_height,
167                                  double           offset_x,
168                                  double           offset_y,
169                                  double           scale_x,
170                                  double           scale_y,
171                                  GdkInterpType    interp_type);
172 void gdk_pixbuf_composite       (const GdkPixbuf *src,
173                                  GdkPixbuf       *dest,
174                                  int              dest_x,
175                                  int              dest_y,
176                                  int              dest_width,
177                                  int              dest_height,
178                                  double           offset_x,
179                                  double           offset_y,
180                                  double           scale_x,
181                                  double           scale_y,
182                                  GdkInterpType    interp_type,
183                                  int              overall_alpha);
184 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
185                                  GdkPixbuf       *dest,
186                                  int              dest_x,
187                                  int              dest_y,
188                                  int              dest_width,
189                                  int              dest_height,
190                                  double           offset_x,
191                                  double           offset_y,
192                                  double           scale_x,
193                                  double           scale_y,
194                                  GdkInterpType    interp_type,
195                                  int              overall_alpha,
196                                  int              check_x,
197                                  int              check_y,
198                                  int              check_size,
199                                  guint32          color1,
200                                  guint32          color2);
201
202 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
203                                               int              dest_width,
204                                               int              dest_height,
205                                               GdkInterpType    interp_type);
206
207 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
208                                               int              dest_width,
209                                               int              dest_height,
210                                               GdkInterpType    interp_type,
211                                               int              overall_alpha,
212                                               int              check_size,
213                                               guint32          color1,
214                                               guint32          color2);
215
216 \f
217
218 /* Animation support */
219
220 /* GIF-like animation overlay modes for frames */
221 typedef enum {
222         GDK_PIXBUF_FRAME_RETAIN,
223         GDK_PIXBUF_FRAME_DISPOSE,
224         GDK_PIXBUF_FRAME_REVERT
225 } GdkPixbufFrameAction;
226
227 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename);
228
229 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
230 void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);
231
232 int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
233 int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
234 GList              *gdk_pixbuf_animation_get_frames      (GdkPixbufAnimation *animation);
235 int                 gdk_pixbuf_animation_get_num_frames  (GdkPixbufAnimation *animation);
236
237 /* Frame accessors */
238
239 GdkPixbuf           *gdk_pixbuf_frame_get_pixbuf     (GdkPixbufFrame *frame);
240 int                  gdk_pixbuf_frame_get_x_offset   (GdkPixbufFrame *frame);
241 int                  gdk_pixbuf_frame_get_y_offset   (GdkPixbufFrame *frame);
242 int                  gdk_pixbuf_frame_get_delay_time (GdkPixbufFrame *frame);
243 GdkPixbufFrameAction gdk_pixbuf_frame_get_action     (GdkPixbufFrame *frame);
244
245
246 /* General (presently empty) initialization hooks, primarily for gnome-libs */
247 void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
248 void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
249
250 \f
251
252 #ifdef __cplusplus
253 }
254 #endif
255
256 #endif