1 /* GdkPixbuf library - GdkPixbuf data structure
3 * Copyright (C) 2003 The Free Software Foundation
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>
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.
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.
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.
26 #if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
27 #error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
30 #ifndef GDK_PIXBUF_CORE_H
31 #define GDK_PIXBUF_CORE_H
34 #include <glib-object.h>
39 /* Alpha compositing mode */
42 GDK_PIXBUF_ALPHA_BILEVEL,
46 /* Color spaces; right now only RGB is supported.
47 * Note that these values are encoded in inline pixbufs
48 * as ints, so don't reorder them
54 /* All of these are opaque structures */
55 typedef struct _GdkPixbuf GdkPixbuf;
57 #define GDK_TYPE_PIXBUF (gdk_pixbuf_get_type ())
58 #define GDK_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
59 #define GDK_IS_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
62 /* Handler that must free the pixel array */
63 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
65 #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
68 /* image data hosed */
69 GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
70 /* no mem to load image */
71 GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
72 /* bad option passed to save routine */
73 GDK_PIXBUF_ERROR_BAD_OPTION,
74 /* unsupported image type (sort of an ENOSYS) */
75 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
76 /* unsupported operation (load, save) for image type */
77 GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
78 GDK_PIXBUF_ERROR_FAILED
81 GQuark gdk_pixbuf_error_quark (void);
85 GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
87 /* GdkPixbuf accessors */
89 GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
90 int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
91 gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
92 int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
93 guchar *gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
94 int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
95 int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
96 int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
100 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
101 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
102 int width, int height);
106 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
108 /* Create a pixbuf which points to the pixels of another pixbuf */
109 GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
118 /* DLL ABI stability hack. */
119 #define gdk_pixbuf_new_from_file gdk_pixbuf_new_from_file_utf8
120 #define gdk_pixbuf_new_from_file_at_size gdk_pixbuf_new_from_file_at_size_utf8
121 #define gdk_pixbuf_new_from_file_at_scale gdk_pixbuf_new_from_file_at_scale_utf8
124 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
126 GdkPixbuf *gdk_pixbuf_new_from_file_at_size (const char *filename,
130 GdkPixbuf *gdk_pixbuf_new_from_file_at_scale (const char *filename,
133 gboolean preserve_aspect_ratio,
136 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
137 GdkColorspace colorspace,
140 int width, int height,
142 GdkPixbufDestroyNotify destroy_fn,
143 gpointer destroy_fn_data);
145 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
146 GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length,
148 gboolean copy_pixels,
152 void gdk_pixbuf_fill (GdkPixbuf *pixbuf,
158 /* DLL ABI stability hack. */
159 #define gdk_pixbuf_save gdk_pixbuf_save_utf8
160 #define gdk_pixbuf_savev gdk_pixbuf_savev_utf8
163 gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf,
164 const char *filename,
167 ...) G_GNUC_NULL_TERMINATED;
169 gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf,
170 const char *filename,
173 char **option_values,
176 /* Saving to a callback function */
178 typedef gboolean (*GdkPixbufSaveFunc) (const gchar *buf,
183 gboolean gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf,
184 GdkPixbufSaveFunc save_func,
188 ...) G_GNUC_NULL_TERMINATED;
190 gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf,
191 GdkPixbufSaveFunc save_func,
195 char **option_values,
198 /* Saving into a newly allocated char array */
200 gboolean gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf,
205 ...) G_GNUC_NULL_TERMINATED;
207 gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf,
212 char **option_values,
215 GdkPixbuf *gdk_pixbuf_new_from_stream (GInputStream *stream,
216 GCancellable *cancellable,
219 GdkPixbuf *gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
222 gboolean preserve_aspect_ratio,
223 GCancellable *cancellable,
226 gboolean gdk_pixbuf_save_to_stream (GdkPixbuf *pixbuf,
227 GOutputStream *stream,
229 GCancellable *cancellable,
233 /* Adding an alpha channel */
234 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
235 guchar r, guchar g, guchar b);
237 /* Copy an area of a pixbuf onto another one */
238 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
239 int src_x, int src_y,
240 int width, int height,
241 GdkPixbuf *dest_pixbuf,
242 int dest_x, int dest_y);
244 /* Brighten/darken and optionally make it pixelated-looking */
245 void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
250 /* Transform an image to agree with its embedded orientation option / tag */
251 GdkPixbuf *gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src);
253 G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
260 #endif /* GDK_PIXBUF_CORE_H */