]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
dc6197891dfe82f38812f49375f2e2f00e48c0f8
[~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  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #ifndef GDK_PIXBUF_H
26 #define GDK_PIXBUF_H
27
28 #include <libart_lgpl/art_misc.h>
29 #include <libart_lgpl/art_pixbuf.h>
30 #include <libart_lgpl/art_filterlevel.h>
31 #include <gdk/gdk.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <gdk-pixbuf/gdk-pixbuf-features.h>
38
39 /* GdkPixbuf structures */
40 typedef struct _GdkPixbuf GdkPixbuf;
41 typedef struct _GdkPixbufFrame GdkPixbufFrame;
42 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
43
44 struct _GdkPixbuf {
45         /* Reference count */
46         int ref_count;
47
48         /* Libart pixbuf */
49         ArtPixBuf *art_pixbuf;
50 };
51
52 /* GIF-like animation overlay modes for frames */
53 typedef enum {
54         GDK_PIXBUF_FRAME_RETAIN,
55         GDK_PIXBUF_FRAME_DISPOSE,
56         GDK_PIXBUF_FRAME_REVERT
57 } GdkPixbufFrameAction;
58
59 struct _GdkPixbufFrame {
60         /* The pixbuf with this frame's image data */
61         GdkPixbuf *pixbuf;
62
63         /* Offsets for overlaying onto the animation's area */
64         int x_offset;
65         int y_offset;
66
67         /* Frame duration in ms */
68         int delay_time;
69
70         /* Overlay mode */
71         GdkPixbufFrameAction action;
72 };
73
74 struct _GdkPixbufAnimation {
75         /* Reference count */
76         int ref_count;
77
78         /* Number of frames */
79         int n_frames;
80
81         /* List of GdkPixbufFrame structures */
82         GList *frames;
83
84         /* bounding box size */
85         int width, height;
86 };
87
88 \f
89
90 /* Convenience functions */
91
92 ArtPixFormat gdk_pixbuf_get_format          (GdkPixbuf *pixbuf);
93 int          gdk_pixbuf_get_n_channels      (GdkPixbuf *pixbuf);
94 gboolean     gdk_pixbuf_get_has_alpha       (GdkPixbuf *pixbuf);
95 int          gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf);
96 guchar      *gdk_pixbuf_get_pixels          (GdkPixbuf *pixbuf);
97 int          gdk_pixbuf_get_width           (GdkPixbuf *pixbuf);
98 int          gdk_pixbuf_get_height          (GdkPixbuf *pixbuf);
99 int          gdk_pixbuf_get_rowstride       (GdkPixbuf *pixbuf);
100
101 /* Reference counting */
102
103 GdkPixbuf *gdk_pixbuf_ref   (GdkPixbuf *pixbuf);
104 void       gdk_pixbuf_unref (GdkPixbuf *pixbuf);
105
106 /* Wrap a libart pixbuf */
107 GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
108
109 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
110 GdkPixbuf *gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
111                            int width, int height);
112
113 /* Simple loading */
114
115 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
116
117 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
118                                      ArtPixFormat format,
119                                      gboolean has_alpha,
120                                      int width, int height,
121                                      int rowstride,
122                                      ArtDestroyNotify dfunc,
123                                      gpointer dfunc_data);
124
125 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
126
127 /* Adding an alpha channel */
128 GdkPixbuf *gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color,
129                                  guchar r, guchar g, guchar b);
130
131 /* Rendering to a drawable */
132
133 /* Alpha compositing mode */
134 typedef enum {
135         GDK_PIXBUF_ALPHA_BILEVEL,
136         GDK_PIXBUF_ALPHA_FULL
137 } GdkPixbufAlphaMode;
138
139 void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
140                                         int src_x, int src_y,
141                                         int dest_x, int dest_y,
142                                         int width, int height,
143                                         int alpha_threshold);
144
145 void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
146                                     GdkDrawable *drawable, GdkGC *gc,
147                                     int src_x, int src_y,
148                                     int dest_x, int dest_y,
149                                     int width, int height,
150                                     GdkRgbDither dither,
151                                     int x_dither, int y_dither);
152
153 void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
154                                           int src_x, int src_y,
155                                           int dest_x, int dest_y,
156                                           int width, int height,
157                                           GdkPixbufAlphaMode alpha_mode,
158                                           int alpha_threshold,
159                                           GdkRgbDither dither,
160                                           int x_dither, int y_dither);
161
162 void gdk_pixbuf_render_pixmap_and_mask   (GdkPixbuf *pixbuf,
163                                           GdkPixmap **pixmap_return, GdkBitmap **mask_return,
164                                           int alpha_threshold);
165
166 /* Fetching a region from a drawable */
167 GdkPixbuf *gdk_pixbuf_get_from_drawable  (GdkPixbuf *dest,
168                                           GdkDrawable *src, GdkColormap *cmap,
169                                           int src_x, int src_y,
170                                           int dest_x, int dest_y,
171                                           int width, int height);
172
173 /* Copy an area of a pixbuf onto another one */
174 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
175                            int src_x, int src_y,
176                            int width, int height,
177                            GdkPixbuf *dest_pixbuf,
178                            int dest_x, int dest_y);
179
180 /* Scaling */
181
182 void gdk_pixbuf_scale           (const GdkPixbuf *src,
183                                  GdkPixbuf       *dest,
184                                  int              dest_x,
185                                  int              dest_y,
186                                  int              dest_width,
187                                  int              dest_height,
188                                  double           offset_x,
189                                  double           offset_y,
190                                  double           scale_x,
191                                  double           scale_y,
192                                  ArtFilterLevel   filter_level);
193 void gdk_pixbuf_composite       (const GdkPixbuf *src,
194                                  GdkPixbuf       *dest,
195                                  int              dest_x,
196                                  int              dest_y,
197                                  int              dest_width,
198                                  int              dest_height,
199                                  double           offset_x,
200                                  double           offset_y,
201                                  double           scale_x,
202                                  double           scale_y,
203                                  ArtFilterLevel   filter_level,
204                                  int              overall_alpha);
205 void gdk_pixbuf_composite_color (const GdkPixbuf *src,
206                                  GdkPixbuf       *dest,
207                                  int              dest_x,
208                                  int              dest_y,
209                                  int              dest_width,
210                                  int              dest_height,
211                                  double           offset_x,
212                                  double           offset_y,
213                                  double           scale_x,
214                                  double           scale_y,
215                                  ArtFilterLevel   filter_level,
216                                  int              overall_alpha,
217                                  int              check_x,
218                                  int              check_y,
219                                  int              check_size,
220                                  art_u32          color1,
221                                  art_u32          color2);
222
223 GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
224                                               int              dest_width,
225                                               int              dest_height,
226                                               ArtFilterLevel   filter_level);
227 GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
228                                               int              dest_width,
229                                               int              dest_height,
230                                               ArtFilterLevel   filter_level,
231                                               int              overall_alpha,
232                                               int              check_size,
233                                               art_u32          color1,
234                                               art_u32          color2);
235
236 /* Animation support */
237
238 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
239
240 GdkPixbufAnimation *gdk_pixbuf_animation_ref   (GdkPixbufAnimation *animation);
241 void                gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
242
243 /* General (presently empty) initialization hooks, primarily for gnome-libs */
244 void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
245 void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
246
247 \f
248
249 #ifdef __cplusplus
250 }
251 #endif
252
253 #endif