]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf-core.h
Document the "orientation" option.
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf-core.h
1 /* GdkPixbuf library - GdkPixbuf data structure
2  *
3  * Copyright (C) 2003 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 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.
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  * Lesser General Public License for more details.
19  *
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.
24  */
25
26 #ifndef GDK_PIXBUF_CORE_H
27 #define GDK_PIXBUF_CORE_H
28
29 #include <glib.h>
30 #include <glib-object.h>
31
32 G_BEGIN_DECLS
33
34 /* Alpha compositing mode */
35 typedef enum
36 {
37         GDK_PIXBUF_ALPHA_BILEVEL,
38         GDK_PIXBUF_ALPHA_FULL
39 } GdkPixbufAlphaMode;
40
41 /* Color spaces; right now only RGB is supported.
42  * Note that these values are encoded in inline pixbufs
43  * as ints, so don't reorder them
44  */
45 typedef enum {
46         GDK_COLORSPACE_RGB
47 } GdkColorspace;
48
49 /* All of these are opaque structures */
50 typedef struct _GdkPixbuf GdkPixbuf;
51
52 #define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
53 #define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
54 #define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
55
56
57 /* Handler that must free the pixel array */
58 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
59
60 #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
61
62 typedef enum {
63         /* image data hosed */
64         GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
65         /* no mem to load image */
66         GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
67         /* bad option passed to save routine */
68         GDK_PIXBUF_ERROR_BAD_OPTION,
69         /* unsupported image type (sort of an ENOSYS) */
70         GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
71         /* unsupported operation (load, save) for image type */
72         GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
73         GDK_PIXBUF_ERROR_FAILED
74 } GdkPixbufError;
75
76 GQuark gdk_pixbuf_error_quark (void);
77
78 \f
79
80 GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
81
82 /* Reference counting */
83
84 #ifndef GDK_PIXBUF_DISABLE_DEPRECATED
85 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
86 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
87 #endif
88
89 /* GdkPixbuf accessors */
90
91 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
92 int           gdk_pixbuf_get_n_channels      (const GdkPixbuf *pixbuf);
93 gboolean      gdk_pixbuf_get_has_alpha       (const GdkPixbuf *pixbuf);
94 int           gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
95 guchar       *gdk_pixbuf_get_pixels          (const GdkPixbuf *pixbuf);
96 int           gdk_pixbuf_get_width           (const GdkPixbuf *pixbuf);
97 int           gdk_pixbuf_get_height          (const GdkPixbuf *pixbuf);
98 int           gdk_pixbuf_get_rowstride       (const GdkPixbuf *pixbuf);
99
100 \f
101
102 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
103 GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
104                            int width, int height);
105
106 /* Copy a pixbuf */
107
108 GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
109
110 /* Create a pixbuf which points to the pixels of another pixbuf */
111 GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
112                                      int        src_x,
113                                      int        src_y,
114                                      int        width,
115                                      int        height);
116
117 /* Simple loading */
118
119 #ifdef G_OS_WIN32
120 /* DLL ABI stability hack. */
121 #define gdk_pixbuf_new_from_file gdk_pixbuf_new_from_file_utf8
122 #define gdk_pixbuf_new_from_file_at_size gdk_pixbuf_new_from_file_at_size_utf8
123 #define gdk_pixbuf_new_from_file_at_scale gdk_pixbuf_new_from_file_at_scale_utf8
124 #endif
125
126 GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
127                                      GError    **error);
128 GdkPixbuf *gdk_pixbuf_new_from_file_at_size (const char *filename,
129                                              int         width, 
130                                              int         height,
131                                              GError    **error);
132 GdkPixbuf *gdk_pixbuf_new_from_file_at_scale (const char *filename,
133                                               int         width, 
134                                               int         height,
135                                               gboolean    preserve_aspect_ratio,
136                                               GError    **error);
137
138 GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
139                                      GdkColorspace colorspace,
140                                      gboolean has_alpha,
141                                      int bits_per_sample,
142                                      int width, int height,
143                                      int rowstride,
144                                      GdkPixbufDestroyNotify destroy_fn,
145                                      gpointer destroy_fn_data);
146
147 GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
148 GdkPixbuf* gdk_pixbuf_new_from_inline   (gint          data_length,
149                                          const guint8 *data,
150                                          gboolean      copy_pixels,
151                                          GError      **error);
152        
153 /* Mutations */
154 void       gdk_pixbuf_fill              (GdkPixbuf    *pixbuf,
155                                          guint32       pixel);
156
157 /* Saving */
158
159 #ifdef G_OS_WIN32
160 /* DLL ABI stability hack. */
161 #define gdk_pixbuf_save gdk_pixbuf_save_utf8
162 #define gdk_pixbuf_savev gdk_pixbuf_savev_utf8
163 #endif
164
165 gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
166                                     const char *filename, 
167                                     const char *type, 
168                                     GError    **error,
169                                     ...) G_GNUC_NULL_TERMINATED;
170
171 gboolean gdk_pixbuf_savev          (GdkPixbuf  *pixbuf, 
172                                     const char *filename, 
173                                     const char *type,
174                                     char      **option_keys,
175                                     char      **option_values,
176                                     GError    **error);
177
178 /* Saving to a callback function */
179
180 typedef gboolean (*GdkPixbufSaveFunc)   (const gchar *buf,
181                                          gsize count,
182                                          GError **error,
183                                          gpointer data);
184
185 gboolean gdk_pixbuf_save_to_callback    (GdkPixbuf  *pixbuf,
186                                          GdkPixbufSaveFunc save_func,
187                                          gpointer user_data,
188                                          const char *type, 
189                                          GError    **error,
190                                          ...) G_GNUC_NULL_TERMINATED;
191
192 gboolean gdk_pixbuf_save_to_callbackv   (GdkPixbuf  *pixbuf, 
193                                          GdkPixbufSaveFunc save_func,
194                                          gpointer user_data,
195                                          const char *type,
196                                          char      **option_keys,
197                                          char      **option_values,
198                                          GError    **error);
199
200 /* Saving into a newly allocated char array */
201
202 gboolean gdk_pixbuf_save_to_buffer      (GdkPixbuf  *pixbuf,
203                                          gchar     **buffer,
204                                          gsize      *buffer_size,
205                                          const char *type, 
206                                          GError    **error,
207                                          ...) G_GNUC_NULL_TERMINATED;
208
209 gboolean gdk_pixbuf_save_to_bufferv     (GdkPixbuf  *pixbuf,
210                                          gchar     **buffer,
211                                          gsize      *buffer_size,
212                                          const char *type, 
213                                          char      **option_keys,
214                                          char      **option_values,
215                                          GError    **error);
216
217 /* Adding an alpha channel */
218 GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
219                                  guchar r, guchar g, guchar b);
220
221 /* Copy an area of a pixbuf onto another one */
222 void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
223                            int src_x, int src_y,
224                            int width, int height,
225                            GdkPixbuf *dest_pixbuf,
226                            int dest_x, int dest_y);
227
228 /* Brighten/darken and optionally make it pixelated-looking */
229 void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
230                                        GdkPixbuf       *dest,
231                                        gfloat           saturation,
232                                        gboolean         pixelate);
233
234 /* Transform an image to agree with its embedded orientation option / tag */
235 GdkPixbuf *gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src);
236
237 G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
238                                               const gchar *key);
239
240
241 G_END_DECLS
242
243
244 #endif /* GDK_PIXBUF_CORE_H */