]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.c
[quartz] Delete the typedef of GdkDevicePrivate
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 /* GdkPixbuf library - Basic memory management
3  *
4  * Copyright (C) 1999 The Free Software Foundation
5  *
6  * Authors: Mark Crichton <crichton@gimp.org>
7  *          Miguel de Icaza <miguel@gnu.org>
8  *          Federico Mena-Quintero <federico@gimp.org>
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 #include "config.h"
27 #include <math.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #define GDK_PIXBUF_C_COMPILATION
31 #include "gdk-pixbuf.h"
32 #include "gdk-pixbuf-private.h"
33 /* Include the marshallers */
34 #include <glib-object.h>
35 #include "gdk-pixbuf-marshal.c"
36 #include "gdk-pixbuf-alias.h"
37
38 static void gdk_pixbuf_finalize     (GObject        *object);
39 static void gdk_pixbuf_set_property (GObject        *object,
40                                      guint           prop_id,
41                                      const GValue   *value,
42                                      GParamSpec     *pspec);
43 static void gdk_pixbuf_get_property (GObject        *object,
44                                      guint           prop_id,
45                                      GValue         *value,
46                                      GParamSpec     *pspec);
47
48 \f
49 enum 
50 {
51   PROP_0,
52   PROP_COLORSPACE,
53   PROP_N_CHANNELS,
54   PROP_HAS_ALPHA,
55   PROP_BITS_PER_SAMPLE,
56   PROP_WIDTH,
57   PROP_HEIGHT,
58   PROP_ROWSTRIDE,
59   PROP_PIXELS
60 };
61
62 G_DEFINE_TYPE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT)
63
64 static void 
65 gdk_pixbuf_init (GdkPixbuf *pixbuf)
66 {
67 }
68
69 static void
70 gdk_pixbuf_class_init (GdkPixbufClass *klass)
71 {
72         GObjectClass *object_class = G_OBJECT_CLASS (klass);
73         
74         object_class->finalize = gdk_pixbuf_finalize;
75         object_class->set_property = gdk_pixbuf_set_property;
76         object_class->get_property = gdk_pixbuf_get_property;
77
78 #define PIXBUF_PARAM_FLAGS G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY|\
79                            G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
80         /**
81          * GdkPixbuf:n-channels:
82          *
83          * The number of samples per pixel. 
84          * Currently, only 3 or 4 samples per pixel are supported.
85          */
86         g_object_class_install_property (object_class,
87                                          PROP_N_CHANNELS,
88                                          g_param_spec_int ("n-channels",
89                                                            P_("Number of Channels"),
90                                                            P_("The number of samples per pixel"),
91                                                            0,
92                                                            G_MAXINT,
93                                                            3,
94                                                            PIXBUF_PARAM_FLAGS));
95
96         g_object_class_install_property (object_class,
97                                          PROP_COLORSPACE,
98                                          g_param_spec_enum ("colorspace",
99                                                             P_("Colorspace"),
100                                                             P_("The colorspace in which the samples are interpreted"),
101                                                             GDK_TYPE_COLORSPACE,
102                                                             GDK_COLORSPACE_RGB,
103                                                             PIXBUF_PARAM_FLAGS));
104
105         g_object_class_install_property (object_class,
106                                          PROP_HAS_ALPHA,
107                                          g_param_spec_boolean ("has-alpha",
108                                                                P_("Has Alpha"),
109                                                                P_("Whether the pixbuf has an alpha channel"),
110                                                                FALSE,
111                                                                PIXBUF_PARAM_FLAGS));
112
113         /**
114          * GdkPixbuf:bits-per-sample:
115          *
116          * The number of bits per sample. 
117          * Currently only 8 bit per sample are supported.
118          */
119         g_object_class_install_property (object_class,
120                                          PROP_BITS_PER_SAMPLE,
121                                          g_param_spec_int ("bits-per-sample",
122                                                            P_("Bits per Sample"),
123                                                            P_("The number of bits per sample"),
124                                                            1,
125                                                            16,
126                                                            8,
127                                                            PIXBUF_PARAM_FLAGS));
128
129         g_object_class_install_property (object_class,
130                                          PROP_WIDTH,
131                                          g_param_spec_int ("width",
132                                                            P_("Width"),
133                                                            P_("The number of columns of the pixbuf"),
134                                                            1,
135                                                            G_MAXINT,
136                                                            1,
137                                                            PIXBUF_PARAM_FLAGS));
138
139         g_object_class_install_property (object_class,
140                                          PROP_HEIGHT,
141                                          g_param_spec_int ("height",
142                                                            P_("Height"),
143                                                            P_("The number of rows of the pixbuf"),
144                                                            1,
145                                                            G_MAXINT,
146                                                            1,
147                                                            PIXBUF_PARAM_FLAGS));
148
149         /**
150          * GdkPixbuf:rowstride:
151          *
152          * The number of bytes between the start of a row and 
153          * the start of the next row. This number must (obviously)
154          * be at least as large as the width of the pixbuf.
155          */
156         g_object_class_install_property (object_class,
157                                          PROP_ROWSTRIDE,
158                                          g_param_spec_int ("rowstride",
159                                                            P_("Rowstride"),
160                                                            P_("The number of bytes between the start of a row and the start of the next row"),
161                                                            1,
162                                                            G_MAXINT,
163                                                            1,
164                                                            PIXBUF_PARAM_FLAGS));
165
166         g_object_class_install_property (object_class,
167                                          PROP_PIXELS,
168                                          g_param_spec_pointer ("pixels",
169                                                                P_("Pixels"),
170                                                                P_("A pointer to the pixel data of the pixbuf"),
171                                                                PIXBUF_PARAM_FLAGS));
172 }
173
174 static void
175 gdk_pixbuf_finalize (GObject *object)
176 {
177         GdkPixbuf *pixbuf = GDK_PIXBUF (object);
178         
179         if (pixbuf->destroy_fn)
180                 (* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
181         
182         G_OBJECT_CLASS (gdk_pixbuf_parent_class)->finalize (object);
183 }
184
185 /* Used as the destroy notification function for gdk_pixbuf_new() */
186 static void
187 free_buffer (guchar *pixels, gpointer data)
188 {
189         g_free (pixels);
190 }
191
192 /**
193  * gdk_pixbuf_new:
194  * @colorspace: Color space for image
195  * @has_alpha: Whether the image should have transparency information
196  * @bits_per_sample: Number of bits per color sample
197  * @width: Width of image in pixels, must be > 0
198  * @height: Height of image in pixels, must be > 0
199  *
200  * Creates a new #GdkPixbuf structure and allocates a buffer for it.  The 
201  * buffer has an optimal rowstride.  Note that the buffer is not cleared;
202  * you will have to fill it completely yourself.
203  *
204  * Return value: A newly-created #GdkPixbuf with a reference count of 1, or 
205  * %NULL if not enough memory could be allocated for the image buffer.
206  **/
207 GdkPixbuf *
208 gdk_pixbuf_new (GdkColorspace colorspace, 
209                 gboolean      has_alpha,
210                 int           bits_per_sample,
211                 int           width,
212                 int           height)
213 {
214         guchar *buf;
215         int channels;
216         int rowstride;
217         gsize bytes;
218
219         g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
220         g_return_val_if_fail (bits_per_sample == 8, NULL);
221         g_return_val_if_fail (width > 0, NULL);
222         g_return_val_if_fail (height > 0, NULL);
223
224         channels = has_alpha ? 4 : 3;
225         rowstride = width * channels;
226         if (rowstride / channels != width || rowstride + 3 < 0) /* overflow */
227                 return NULL;
228         
229         /* Always align rows to 32-bit boundaries */
230         rowstride = (rowstride + 3) & ~3;
231
232         bytes = height * rowstride;
233         if (bytes / rowstride !=  height) /* overflow */
234                 return NULL;
235             
236         buf = g_try_malloc (bytes);
237         if (!buf)
238                 return NULL;
239
240         return gdk_pixbuf_new_from_data (buf, colorspace, has_alpha, bits_per_sample,
241                                          width, height, rowstride,
242                                          free_buffer, NULL);
243 }
244
245 /**
246  * gdk_pixbuf_copy:
247  * @pixbuf: A pixbuf.
248  * 
249  * Creates a new #GdkPixbuf with a copy of the information in the specified
250  * @pixbuf.
251  * 
252  * Return value: A newly-created pixbuf with a reference count of 1, or %NULL if
253  * not enough memory could be allocated.
254  **/
255 GdkPixbuf *
256 gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
257 {
258         guchar *buf;
259         int size;
260
261         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
262
263         /* Calculate a semi-exact size.  Here we copy with full rowstrides;
264          * maybe we should copy each row individually with the minimum
265          * rowstride?
266          */
267
268         size = ((pixbuf->height - 1) * pixbuf->rowstride +
269                 pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
270
271         buf = g_try_malloc (size * sizeof (guchar));
272         if (!buf)
273                 return NULL;
274
275         memcpy (buf, pixbuf->pixels, size);
276
277         return gdk_pixbuf_new_from_data (buf,
278                                          pixbuf->colorspace, pixbuf->has_alpha,
279                                          pixbuf->bits_per_sample,
280                                          pixbuf->width, pixbuf->height,
281                                          pixbuf->rowstride,
282                                          free_buffer,
283                                          NULL);
284 }
285
286 /**
287  * gdk_pixbuf_new_subpixbuf:
288  * @src_pixbuf: a #GdkPixbuf
289  * @src_x: X coord in @src_pixbuf
290  * @src_y: Y coord in @src_pixbuf
291  * @width: width of region in @src_pixbuf
292  * @height: height of region in @src_pixbuf
293  * 
294  * Creates a new pixbuf which represents a sub-region of
295  * @src_pixbuf. The new pixbuf shares its pixels with the
296  * original pixbuf, so writing to one affects both.
297  * The new pixbuf holds a reference to @src_pixbuf, so
298  * @src_pixbuf will not be finalized until the new pixbuf
299  * is finalized.
300  * 
301  * Return value: a new pixbuf 
302  **/
303 GdkPixbuf*
304 gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
305                           int        src_x,
306                           int        src_y,
307                           int        width,
308                           int        height)
309 {
310         guchar *pixels;
311         GdkPixbuf *sub;
312
313         g_return_val_if_fail (GDK_IS_PIXBUF (src_pixbuf), NULL);
314         g_return_val_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width, NULL);
315         g_return_val_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height, NULL);
316
317         pixels = (gdk_pixbuf_get_pixels (src_pixbuf)
318                   + src_y * src_pixbuf->rowstride
319                   + src_x * src_pixbuf->n_channels);
320
321         sub = gdk_pixbuf_new_from_data (pixels,
322                                         src_pixbuf->colorspace,
323                                         src_pixbuf->has_alpha,
324                                         src_pixbuf->bits_per_sample,
325                                         width, height,
326                                         src_pixbuf->rowstride,
327                                         NULL, NULL);
328
329         /* Keep a reference to src_pixbuf */
330         g_object_ref (src_pixbuf);
331   
332         g_object_set_qdata_full (G_OBJECT (sub),
333                                  g_quark_from_static_string ("gdk-pixbuf-subpixbuf-src"),
334                                  src_pixbuf,
335                                  (GDestroyNotify) g_object_unref);
336
337         return sub;
338 }
339
340 \f
341
342 /* Accessors */
343
344 /**
345  * gdk_pixbuf_get_colorspace:
346  * @pixbuf: A pixbuf.
347  *
348  * Queries the color space of a pixbuf.
349  *
350  * Return value: Color space.
351  **/
352 GdkColorspace
353 gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf)
354 {
355         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), GDK_COLORSPACE_RGB);
356
357         return pixbuf->colorspace;
358 }
359
360 /**
361  * gdk_pixbuf_get_n_channels:
362  * @pixbuf: A pixbuf.
363  *
364  * Queries the number of channels of a pixbuf.
365  *
366  * Return value: Number of channels.
367  **/
368 int
369 gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
370 {
371         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
372
373         return pixbuf->n_channels;
374 }
375
376 /**
377  * gdk_pixbuf_get_has_alpha:
378  * @pixbuf: A pixbuf.
379  *
380  * Queries whether a pixbuf has an alpha channel (opacity information).
381  *
382  * Return value: %TRUE if it has an alpha channel, %FALSE otherwise.
383  **/
384 gboolean
385 gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
386 {
387         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
388
389         return pixbuf->has_alpha ? TRUE : FALSE;
390 }
391
392 /**
393  * gdk_pixbuf_get_bits_per_sample:
394  * @pixbuf: A pixbuf.
395  *
396  * Queries the number of bits per color sample in a pixbuf.
397  *
398  * Return value: Number of bits per color sample.
399  **/
400 int
401 gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf)
402 {
403         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
404
405         return pixbuf->bits_per_sample;
406 }
407
408 /**
409  * gdk_pixbuf_get_pixels:
410  * @pixbuf: A pixbuf.
411  *
412  * Queries a pointer to the pixel data of a pixbuf.
413  *
414  * Return value: A pointer to the pixbuf's pixel data.  Please see <xref linkend="image-data"/>
415  * for information about how the pixel data is stored in
416  * memory.
417  **/
418 guchar *
419 gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
420 {
421         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
422
423         return pixbuf->pixels;
424 }
425
426 /**
427  * gdk_pixbuf_get_width:
428  * @pixbuf: A pixbuf.
429  *
430  * Queries the width of a pixbuf.
431  *
432  * Return value: Width in pixels.
433  **/
434 int
435 gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
436 {
437         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
438
439         return pixbuf->width;
440 }
441
442 /**
443  * gdk_pixbuf_get_height:
444  * @pixbuf: A pixbuf.
445  *
446  * Queries the height of a pixbuf.
447  *
448  * Return value: Height in pixels.
449  **/
450 int
451 gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
452 {
453         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
454
455         return pixbuf->height;
456 }
457
458 /**
459  * gdk_pixbuf_get_rowstride:
460  * @pixbuf: A pixbuf.
461  *
462  * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
463  * and the start of the next row.
464  *
465  * Return value: Distance between row starts.
466  **/
467 int
468 gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf)
469 {
470         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
471
472         return pixbuf->rowstride;
473 }
474
475 \f
476
477 /* General initialization hooks */
478 const guint gdk_pixbuf_major_version = GDK_PIXBUF_MAJOR;
479 const guint gdk_pixbuf_minor_version = GDK_PIXBUF_MINOR;
480 const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
481
482 const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
483
484 /* Error quark */
485 GQuark
486 gdk_pixbuf_error_quark (void)
487 {
488   return g_quark_from_static_string ("gdk-pixbuf-error-quark");
489 }
490
491 /**
492  * gdk_pixbuf_fill:
493  * @pixbuf: a #GdkPixbuf
494  * @pixel: RGBA pixel to clear to
495  *         (0xffffffff is opaque white, 0x00000000 transparent black)
496  *
497  * Clears a pixbuf to the given RGBA value, converting the RGBA value into
498  * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
499  * doesn't have an alpha channel.
500  * 
501  **/
502 void
503 gdk_pixbuf_fill (GdkPixbuf *pixbuf,
504                  guint32    pixel)
505 {
506         guchar *pixels;
507         guint r, g, b, a;
508         guchar *p;
509         guint w, h;
510
511         g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
512
513         if (pixbuf->width == 0 || pixbuf->height == 0)
514                 return;
515
516         pixels = pixbuf->pixels;
517
518         r = (pixel & 0xff000000) >> 24;
519         g = (pixel & 0x00ff0000) >> 16;
520         b = (pixel & 0x0000ff00) >> 8;
521         a = (pixel & 0x000000ff);
522
523         h = pixbuf->height;
524         
525         while (h--) {
526                 w = pixbuf->width;
527                 p = pixels;
528
529                 switch (pixbuf->n_channels) {
530                 case 3:
531                         while (w--) {
532                                 p[0] = r;
533                                 p[1] = g;
534                                 p[2] = b;
535                                 p += 3;
536                         }
537                         break;
538                 case 4:
539                         while (w--) {
540                                 p[0] = r;
541                                 p[1] = g;
542                                 p[2] = b;
543                                 p[3] = a;
544                                 p += 4;
545                         }
546                         break;
547                 default:
548                         break;
549                 }
550                 
551                 pixels += pixbuf->rowstride;
552         }
553 }
554
555 \f
556
557 /**
558  * gdk_pixbuf_get_option:
559  * @pixbuf: a #GdkPixbuf
560  * @key: a nul-terminated string.
561  * 
562  * Looks up @key in the list of options that may have been attached to the
563  * @pixbuf when it was loaded, or that may have been attached by another
564  * function using gdk_pixbuf_set_option().
565  *
566  * For instance, the ANI loader provides "Title" and "Artist" options. 
567  * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot 
568  * options for cursor definitions. The PNG loader provides the tEXt ancillary
569  * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
570  * return an "orientation" option string that corresponds to the embedded 
571  * TIFF/Exif orientation tag (if present).
572  * 
573  * Return value: the value associated with @key. This is a nul-terminated 
574  * string that should not be freed or %NULL if @key was not found.
575  **/
576 G_CONST_RETURN gchar *
577 gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
578                        const gchar *key)
579 {
580         gchar **options;
581         gint i;
582
583         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
584         g_return_val_if_fail (key != NULL, NULL);
585   
586         options = g_object_get_qdata (G_OBJECT (pixbuf), 
587                                       g_quark_from_static_string ("gdk_pixbuf_options"));
588         if (options) {
589                 for (i = 0; options[2*i]; i++) {
590                         if (strcmp (options[2*i], key) == 0)
591                                 return options[2*i+1];
592                 }
593         }
594         
595         return NULL;
596 }
597
598 /**
599  * gdk_pixbuf_set_option:
600  * @pixbuf: a #GdkPixbuf
601  * @key: a nul-terminated string.
602  * @value: a nul-terminated string.
603  * 
604  * Attaches a key/value pair as an option to a #GdkPixbuf. If %key already
605  * exists in the list of options attached to @pixbuf, the new value is 
606  * ignored and %FALSE is returned.
607  *
608  * Return value: %TRUE on success.
609  *
610  * Since: 2.2
611  **/
612 gboolean
613 gdk_pixbuf_set_option (GdkPixbuf   *pixbuf,
614                        const gchar *key,
615                        const gchar *value)
616 {
617         GQuark  quark;
618         gchar **options;
619         gint n = 0;
620  
621         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
622         g_return_val_if_fail (key != NULL, FALSE);
623         g_return_val_if_fail (value != NULL, FALSE);
624
625         quark = g_quark_from_static_string ("gdk_pixbuf_options");
626
627         options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
628
629         if (options) {
630                 for (n = 0; options[2*n]; n++) {
631                         if (strcmp (options[2*n], key) == 0)
632                                 return FALSE;
633                 }
634
635                 g_object_steal_qdata (G_OBJECT (pixbuf), quark);
636                 options = g_renew (gchar *, options, 2*(n+1) + 1);
637         } else {
638                 options = g_new (gchar *, 3);
639         }
640         
641         options[2*n]   = g_strdup (key);
642         options[2*n+1] = g_strdup (value);
643         options[2*n+2] = NULL;
644
645         g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
646                                  options, (GDestroyNotify) g_strfreev);
647         
648         return TRUE;
649 }
650
651 static void
652 gdk_pixbuf_set_property (GObject         *object,
653                          guint            prop_id,
654                          const GValue    *value,
655                          GParamSpec      *pspec)
656 {
657   GdkPixbuf *pixbuf = GDK_PIXBUF (object);
658
659   switch (prop_id)
660           {
661           case PROP_COLORSPACE:
662                   pixbuf->colorspace = g_value_get_enum (value);
663                   break;
664           case PROP_N_CHANNELS:
665                   pixbuf->n_channels = g_value_get_int (value);
666                   break;
667           case PROP_HAS_ALPHA:
668                   pixbuf->has_alpha = g_value_get_boolean (value);
669                   break;
670           case PROP_BITS_PER_SAMPLE:
671                   pixbuf->bits_per_sample = g_value_get_int (value);
672                   break;
673           case PROP_WIDTH:
674                   pixbuf->width = g_value_get_int (value);
675                   break;
676           case PROP_HEIGHT:
677                   pixbuf->height = g_value_get_int (value);
678                   break;
679           case PROP_ROWSTRIDE:
680                   pixbuf->rowstride = g_value_get_int (value);
681                   break;
682           case PROP_PIXELS:
683                   pixbuf->pixels = (guchar *) g_value_get_pointer (value);
684                   break;
685           default:
686                   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
687                   break;
688           }
689 }
690
691 static void
692 gdk_pixbuf_get_property (GObject         *object,
693                          guint            prop_id,
694                          GValue          *value,
695                          GParamSpec      *pspec)
696 {
697   GdkPixbuf *pixbuf = GDK_PIXBUF (object);
698   
699   switch (prop_id)
700           {
701           case PROP_COLORSPACE:
702                   g_value_set_enum (value, gdk_pixbuf_get_colorspace (pixbuf));
703                   break;
704           case PROP_N_CHANNELS:
705                   g_value_set_int (value, gdk_pixbuf_get_n_channels (pixbuf));
706                   break;
707           case PROP_HAS_ALPHA:
708                   g_value_set_boolean (value, gdk_pixbuf_get_has_alpha (pixbuf));
709                   break;
710           case PROP_BITS_PER_SAMPLE:
711                   g_value_set_int (value, gdk_pixbuf_get_bits_per_sample (pixbuf));
712                   break;
713           case PROP_WIDTH:
714                   g_value_set_int (value, gdk_pixbuf_get_width (pixbuf));
715                   break;
716           case PROP_HEIGHT:
717                   g_value_set_int (value, gdk_pixbuf_get_height (pixbuf));
718                   break;
719           case PROP_ROWSTRIDE:
720                   g_value_set_int (value, gdk_pixbuf_get_rowstride (pixbuf));
721                   break;
722           case PROP_PIXELS:
723                   g_value_set_pointer (value, gdk_pixbuf_get_pixels (pixbuf));
724                   break;
725           default:
726                   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
727                   break;
728           }
729 }
730
731 #define __GDK_PIXBUF_C__
732 #include "gdk-pixbuf-aliasdef.c"