]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.h
Removed the broken --enable-canvas-pixbuf option. Added the stuff
[~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
85 \f
86
87 /* Convenience functions */
88
89 ArtPixFormat gdk_pixbuf_get_format          (GdkPixbuf *pixbuf);
90 int          gdk_pixbuf_get_n_channels      (GdkPixbuf *pixbuf);
91 int          gdk_pixbuf_get_has_alpha       (GdkPixbuf *pixbuf);
92 int          gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf);
93 guchar      *gdk_pixbuf_get_pixels          (GdkPixbuf *pixbuf);
94 int          gdk_pixbuf_get_width           (GdkPixbuf *pixbuf);
95 int          gdk_pixbuf_get_height          (GdkPixbuf *pixbuf);
96 int          gdk_pixbuf_get_rowstride       (GdkPixbuf *pixbuf);
97
98 /* Reference counting */
99
100 void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
101 void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
102
103 /* Wrap a libart pixbuf */
104 GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
105
106 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
107 GdkPixbuf *gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
108                            int width, int height);
109
110 /* Simple loading */
111
112 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
113
114 GdkPixbuf *gdk_pixbuf_new_from_data (guchar *data,
115                                      ArtPixFormat format,
116                                      gboolean has_alpha,
117                                      int width, int height,
118                                      int rowstride,
119                                      ArtDestroyNotify dfunc,
120                                      gpointer dfunc_data);
121
122 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
123
124 /* Adding an alpha channel */
125 GdkPixbuf *gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color,
126                                  guchar r, guchar g, guchar b);
127
128 /* Rendering to a drawable */
129
130 /* Alpha compositing mode */
131 typedef enum {
132         GDK_PIXBUF_ALPHA_BILEVEL,
133         GDK_PIXBUF_ALPHA_FULL
134 } GdkPixbufAlphaMode;
135
136 void gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
137                                         int src_x, int src_y,
138                                         int dest_x, int dest_y,
139                                         int width, int height,
140                                         int alpha_threshold);
141
142 void gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
143                                     GdkDrawable *drawable, GdkGC *gc,
144                                     int src_x, int src_y,
145                                     int dest_x, int dest_y,
146                                     int width, int height,
147                                     GdkRgbDither dither,
148                                     int x_dither, int y_dither);
149
150 void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
151                                           int src_x, int src_y,
152                                           int dest_x, int dest_y,
153                                           int width, int height,
154                                           GdkPixbufAlphaMode alpha_mode,
155                                           int alpha_threshold,
156                                           GdkRgbDither dither,
157                                           int x_dither, int y_dither);
158
159 void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
160                                         GdkPixmap **pixmap_return, GdkBitmap **mask_return,
161                                         int alpha_threshold);
162
163 /* Fetching a region from a drawable */
164 GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
165                                          GdkDrawable *src, GdkColormap *cmap,
166                                          int src_x, int src_y,
167                                          int dest_x, int dest_y,
168                                          int width, int height);
169
170 /* Copy an area of a pixbuf onto another one */
171 void gdk_pixbuf_copy_area (GdkPixbuf *src_pixbuf,
172                            int src_x, int src_y,
173                            int width, int height,
174                            GdkPixbuf *dest_pixbuf,
175                            int dest_x, int dest_y);
176
177 /* Scaling */
178
179 void gdk_pixbuf_scale           (GdkPixbuf      *src,
180                                  GdkPixbuf      *dest,
181                                  int             dest_x,
182                                  int             dest_y,
183                                  int             dest_width,
184                                  int             dest_height,
185                                  double          offset_x,
186                                  double          offset_y,
187                                  double          scale_x,
188                                  double          scale_y,
189                                  ArtFilterLevel  filter_level);
190 void gdk_pixbuf_composite       (GdkPixbuf      *src,
191                                  GdkPixbuf      *dest,
192                                  int             dest_x,
193                                  int             dest_y,
194                                  int             dest_width,
195                                  int             dest_height,
196                                  double          offset_x,
197                                  double          offset_y,
198                                  double          scale_x,
199                                  double          scale_y,
200                                  ArtFilterLevel  filter_level,
201                                  int             overall_alpha);
202 void gdk_pixbuf_composite_color (GdkPixbuf      *src,
203                                  GdkPixbuf      *dest,
204                                  int             dest_x,
205                                  int             dest_y,
206                                  int             dest_width,
207                                  int             dest_height,
208                                  double          offset_x,
209                                  double          offset_y,
210                                  double          scale_x,
211                                  double          scale_y,
212                                  ArtFilterLevel  filter_level,
213                                  int             overall_alpha,
214                                  int             check_x,
215                                  int             check_y,
216                                  int             check_size,
217                                  art_u32         color1,
218                                  art_u32         color2);
219
220 GdkPixbuf *gdk_pixbuf_scale_simple           (GdkPixbuf      *src,
221                                               int             dest_width,
222                                               int             dest_height,
223                                               ArtFilterLevel  filter_level);
224 GdkPixbuf *gdk_pixbuf_composite_color_simple (GdkPixbuf      *src,
225                                               int             dest_width,
226                                               int             dest_height,
227                                               ArtFilterLevel  filter_level,
228                                               int             overall_alpha,
229                                               int             check_size,
230                                               art_u32         color1,
231                                               art_u32         color2);
232
233 /* Animation support */
234
235 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
236
237 void gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
238 void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
239
240 /* General (presently empty) initialization hooks, primarily for gnome-libs */
241 void gdk_pixbuf_preinit(gpointer app, gpointer modinfo);
242 void gdk_pixbuf_postinit(gpointer app, gpointer modinfo);
243
244 \f
245
246 #ifdef __cplusplus
247 }
248 #endif
249
250 #endif