gdk-pixbuf.h 10.9 KB
Newer Older
1
/* GdkPixbuf library - Main header file
2 3 4 5 6 7
 *
 * Copyright (C) 1999 The Free Software Foundation
 *
 * Authors: Mark Crichton <crichton@gimp.org>
 *          Miguel de Icaza <miguel@gnu.org>
 *          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 13 14 15 16 17
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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 22 23 24 25 26 27
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef GDK_PIXBUF_H
#define GDK_PIXBUF_H
Arturo Espinosa's avatar
Arturo Espinosa committed
28

Owen Taylor's avatar
Owen Taylor committed
29
#include <glib.h>
30
#include <gdk-pixbuf/gdk-pixbuf-features.h>
31
#include <glib-object.h>
Michael Meeks's avatar
Michael Meeks committed
32

33 34 35 36
#ifdef __cplusplus
extern "C" {
#endif

37

Arturo Espinosa's avatar
Arturo Espinosa committed
38

Havoc Pennington's avatar
Havoc Pennington committed
39 40 41
/* Alpha compositing mode */
typedef enum
{
Havoc Pennington's avatar
Havoc Pennington committed
42 43
        GDK_PIXBUF_ALPHA_BILEVEL,
        GDK_PIXBUF_ALPHA_FULL
Havoc Pennington's avatar
Havoc Pennington committed
44 45
} GdkPixbufAlphaMode;

46 47 48 49
/* Color spaces; right now only RGB is supported.
 * Note that these values are encoded in inline pixbufs
 * as ints, so don't reorder them
 */
50
typedef enum {
51 52
	GDK_COLORSPACE_RGB
} GdkColorspace;
Jonathan Blandford's avatar
Jonathan Blandford committed
53

54 55 56
/* All of these are opaque structures */
typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
Havoc Pennington's avatar
Havoc Pennington committed
57
typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
58 59 60 61 62 63 64 65 66 67
typedef struct _GdkPixbufFrame GdkPixbufFrame;

#define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
#define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
#define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))

#define GDK_TYPE_PIXBUF_ANIMATION              (gdk_pixbuf_animation_get_type ())
#define GDK_PIXBUF_ANIMATION(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
#define GDK_IS_PIXBUF_ANIMATION(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))

Havoc Pennington's avatar
Havoc Pennington committed
68 69 70
#define GDK_TYPE_PIXBUF_ANIMATION_ITER              (gdk_pixbuf_animation_iter_get_type ())
#define GDK_PIXBUF_ANIMATION_ITER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
#define GDK_IS_PIXBUF_ANIMATION_ITER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
Radek Doulik's avatar
Radek Doulik committed
71

72
/* Handler that must free the pixel array */
73
typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
Jonathan Blandford's avatar
Jonathan Blandford committed
74

75 76 77
#define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()

typedef enum {
78 79 80 81 82 83
        /* stream header corrupt */
	GDK_PIXBUF_ERROR_HEADER_CORRUPT,
        /* stream pixel data corrupt */
	GDK_PIXBUF_ERROR_PIXEL_CORRUPT,
        /* stream header corrupt */
	GDK_PIXBUF_ERROR_UNKNOWN_FORMAT,
Havoc Pennington's avatar
Havoc Pennington committed
84 85 86 87
        /* image data hosed */
        GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
        /* no mem to load image */
        GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
88 89
        /* bad option value passed to save routine */
        GDK_PIXBUF_ERROR_BAD_OPTION_VALUE,
90 91
        /* unsupported image type (sort of an ENOSYS) */
        GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
Havoc Pennington's avatar
Havoc Pennington committed
92 93
        /* unsupported operation (load, save) for image type */
        GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
94
        GDK_PIXBUF_ERROR_FAILED
Havoc Pennington's avatar
Havoc Pennington committed
95
} GdkPixbufError;
96

97
GQuark gdk_pixbuf_error_quark (void) G_GNUC_CONST;
98

99 100


Elliot Lee's avatar
Elliot Lee committed
101
GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
102

103
/* Reference counting */
104

105 106 107
GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);

108 109 110 111 112 113 114 115 116 117 118 119
/* GdkPixbuf accessors */

GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);


120

121
/* Create a blank pixbuf with an optimal rowstride and a new buffer */
122
GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
123
			   int width, int height);
124

125 126 127 128
/* Copy a pixbuf */

GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);

129 130 131 132 133 134 135
/* Create a pixbuf which points to the pixels of another pixbuf */
GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
                                     int        src_x,
                                     int        src_y,
                                     int        width,
                                     int        height);

136 137
/* Simple loading */

Havoc Pennington's avatar
Havoc Pennington committed
138 139
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
                                     GError    **error);
140

Elliot Lee's avatar
Elliot Lee committed
141
GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
142
				     GdkColorspace colorspace,
143
				     gboolean has_alpha,
144
				     int bits_per_sample,
145 146
				     int width, int height,
				     int rowstride,
147 148
				     GdkPixbufDestroyNotify destroy_fn,
				     gpointer destroy_fn_data);
149

150
GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
151 152 153 154 155
GdkPixbuf* gdk_pixbuf_new_from_stream	(gint          stream_length,
					 const guint8 *stream,
					 gboolean      copy_pixels,
					 GError      **error);
       
156 157 158
/* Mutations */
void       gdk_pixbuf_fill              (GdkPixbuf    *pixbuf,
                                         guint32       pixel);
159 160 161 162 163

/* Saving */

gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
                                    const char *filename, 
Havoc Pennington's avatar
Havoc Pennington committed
164 165
                                    const char *type, 
                                    GError    **error,
166 167 168 169
                                    ...);

gboolean gdk_pixbuf_savev          (GdkPixbuf  *pixbuf, 
                                    const char *filename, 
Havoc Pennington's avatar
Havoc Pennington committed
170
                                    const char *type,
171 172
                                    char      **option_keys,
                                    char      **option_values,
Havoc Pennington's avatar
Havoc Pennington committed
173
                                    GError    **error);
174

175
/* Adding an alpha channel */
176
GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
177 178
				 guchar r, guchar g, guchar b);

179 180 181 182 183 184 185
/* Copy an area of a pixbuf onto another one */
void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
			   int src_x, int src_y,
			   int width, int height,
			   GdkPixbuf *dest_pixbuf,
			   int dest_x, int dest_y);

186 187 188 189 190 191
/* Brighten/darken and optionally make it pixelated-looking */
void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
                                       GdkPixbuf       *dest,
                                       gfloat           saturation,
                                       gboolean         pixelate);

192 193


194
/* Rendering to a drawable */
195

196

197 198
/* Scaling */

199 200 201 202 203 204 205 206
/* Interpolation modes */
typedef enum {
	GDK_INTERP_NEAREST,
	GDK_INTERP_TILES,
	GDK_INTERP_BILINEAR,
	GDK_INTERP_HYPER
} GdkInterpType;

207 208 209 210 211 212 213 214 215 216
void gdk_pixbuf_scale           (const GdkPixbuf *src,
				 GdkPixbuf       *dest,
				 int              dest_x,
				 int              dest_y,
				 int              dest_width,
				 int              dest_height,
				 double           offset_x,
				 double           offset_y,
				 double           scale_x,
				 double           scale_y,
217
				 GdkInterpType    interp_type);
218 219 220 221 222 223 224 225 226 227
void gdk_pixbuf_composite       (const GdkPixbuf *src,
				 GdkPixbuf       *dest,
				 int              dest_x,
				 int              dest_y,
				 int              dest_width,
				 int              dest_height,
				 double           offset_x,
				 double           offset_y,
				 double           scale_x,
				 double           scale_y,
228
				 GdkInterpType    interp_type,
229 230 231 232 233 234 235 236 237 238 239
				 int              overall_alpha);
void gdk_pixbuf_composite_color (const GdkPixbuf *src,
				 GdkPixbuf       *dest,
				 int              dest_x,
				 int              dest_y,
				 int              dest_width,
				 int              dest_height,
				 double           offset_x,
				 double           offset_y,
				 double           scale_x,
				 double           scale_y,
240
				 GdkInterpType    interp_type,
241 242 243 244
				 int              overall_alpha,
				 int              check_x,
				 int              check_y,
				 int              check_size,
245 246
				 guint32          color1,
				 guint32          color2);
247 248 249 250

GdkPixbuf *gdk_pixbuf_scale_simple           (const GdkPixbuf *src,
					      int              dest_width,
					      int              dest_height,
251 252
					      GdkInterpType    interp_type);

253 254 255
GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
					      int              dest_width,
					      int              dest_height,
256
					      GdkInterpType    interp_type,
257 258
					      int              overall_alpha,
					      int              check_size,
259 260 261 262
					      guint32          color1,
					      guint32          color2);


263

264
/* Animation support */
Jonathan Blandford's avatar
Jonathan Blandford committed
265

Elliot Lee's avatar
Elliot Lee committed
266
GType               gdk_pixbuf_animation_get_type        (void) G_GNUC_CONST;
267

Havoc Pennington's avatar
Havoc Pennington committed
268 269
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename,
                                                          GError            **error);
Jonathan Blandford's avatar
Jonathan Blandford committed
270

Ettore Perazzoli's avatar
Ettore Perazzoli committed
271 272 273 274 275
GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
void                gdk_pixbuf_animation_unref           (GdkPixbufAnimation *animation);

int                 gdk_pixbuf_animation_get_width       (GdkPixbufAnimation *animation);
int                 gdk_pixbuf_animation_get_height      (GdkPixbufAnimation *animation);
Havoc Pennington's avatar
Havoc Pennington committed
276 277
gboolean            gdk_pixbuf_animation_is_static_image  (GdkPixbufAnimation *animation);
GdkPixbuf          *gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
278

Havoc Pennington's avatar
Havoc Pennington committed
279 280 281 282 283 284 285 286
GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter                        (GdkPixbufAnimation     *animation,
                                                                              const GTimeVal         *start_time);
GType                   gdk_pixbuf_animation_iter_get_type                   (void) G_GNUC_CONST;
int                     gdk_pixbuf_animation_iter_get_delay_time             (GdkPixbufAnimationIter *iter);
GdkPixbuf              *gdk_pixbuf_animation_iter_get_pixbuf                 (GdkPixbufAnimationIter *iter);
gboolean                gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
gboolean                gdk_pixbuf_animation_iter_advance                    (GdkPixbufAnimationIter *iter,
                                                                              const GTimeVal         *current_time);
287 288


Havoc Pennington's avatar
Havoc Pennington committed
289
 
290
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
291
#include <gdk-pixbuf/gdk-pixbuf-enum-types.h>
292

293

294

295 296 297
#ifdef __cplusplus
}
#endif
298

299
#endif