]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/gdk-pixbuf.c
Updated Slovenian translation
[~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 \f
185
186 /**
187  * gdk_pixbuf_ref:
188  * @pixbuf: A pixbuf.
189  *
190  * Adds a reference to a pixbuf. 
191  *
192  * Return value: The same as the @pixbuf argument.
193  *
194  * Deprecated: Use g_object_ref().
195  **/
196 GdkPixbuf *
197 gdk_pixbuf_ref (GdkPixbuf *pixbuf)
198 {
199         return (GdkPixbuf *) g_object_ref (pixbuf);
200 }
201
202 /**
203  * gdk_pixbuf_unref:
204  * @pixbuf: A pixbuf.
205  *
206  * Removes a reference from a pixbuf. 
207  *
208  * Deprecated: Use g_object_unref().
209  **/
210 void
211 gdk_pixbuf_unref (GdkPixbuf *pixbuf)
212 {
213         g_object_unref (pixbuf);
214 }
215
216 \f
217
218 /* Used as the destroy notification function for gdk_pixbuf_new() */
219 static void
220 free_buffer (guchar *pixels, gpointer data)
221 {
222         g_free (pixels);
223 }
224
225 /**
226  * gdk_pixbuf_new:
227  * @colorspace: Color space for image
228  * @has_alpha: Whether the image should have transparency information
229  * @bits_per_sample: Number of bits per color sample
230  * @width: Width of image in pixels, must be > 0
231  * @height: Height of image in pixels, must be > 0
232  *
233  * Creates a new #GdkPixbuf structure and allocates a buffer for it.  The 
234  * buffer has an optimal rowstride.  Note that the buffer is not cleared;
235  * you will have to fill it completely yourself.
236  *
237  * Return value: A newly-created #GdkPixbuf with a reference count of 1, or 
238  * %NULL if not enough memory could be allocated for the image buffer.
239  **/
240 GdkPixbuf *
241 gdk_pixbuf_new (GdkColorspace colorspace, 
242                 gboolean      has_alpha,
243                 int           bits_per_sample,
244                 int           width,
245                 int           height)
246 {
247         guchar *buf;
248         int channels;
249         int rowstride;
250         gsize bytes;
251
252         g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
253         g_return_val_if_fail (bits_per_sample == 8, NULL);
254         g_return_val_if_fail (width > 0, NULL);
255         g_return_val_if_fail (height > 0, NULL);
256
257         channels = has_alpha ? 4 : 3;
258         rowstride = width * channels;
259         if (rowstride / channels != width || rowstride + 3 < 0) /* overflow */
260                 return NULL;
261         
262         /* Always align rows to 32-bit boundaries */
263         rowstride = (rowstride + 3) & ~3;
264
265         bytes = height * rowstride;
266         if (bytes / rowstride !=  height) /* overflow */
267                 return NULL;
268             
269         buf = g_try_malloc (bytes);
270         if (!buf)
271                 return NULL;
272
273         return gdk_pixbuf_new_from_data (buf, colorspace, has_alpha, bits_per_sample,
274                                          width, height, rowstride,
275                                          free_buffer, NULL);
276 }
277
278 /**
279  * gdk_pixbuf_copy:
280  * @pixbuf: A pixbuf.
281  * 
282  * Creates a new #GdkPixbuf with a copy of the information in the specified
283  * @pixbuf.
284  * 
285  * Return value: A newly-created pixbuf with a reference count of 1, or %NULL if
286  * not enough memory could be allocated.
287  **/
288 GdkPixbuf *
289 gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
290 {
291         guchar *buf;
292         int size;
293
294         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
295
296         /* Calculate a semi-exact size.  Here we copy with full rowstrides;
297          * maybe we should copy each row individually with the minimum
298          * rowstride?
299          */
300
301         size = ((pixbuf->height - 1) * pixbuf->rowstride +
302                 pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
303
304         buf = g_try_malloc (size * sizeof (guchar));
305         if (!buf)
306                 return NULL;
307
308         memcpy (buf, pixbuf->pixels, size);
309
310         return gdk_pixbuf_new_from_data (buf,
311                                          pixbuf->colorspace, pixbuf->has_alpha,
312                                          pixbuf->bits_per_sample,
313                                          pixbuf->width, pixbuf->height,
314                                          pixbuf->rowstride,
315                                          free_buffer,
316                                          NULL);
317 }
318
319 /**
320  * gdk_pixbuf_new_subpixbuf:
321  * @src_pixbuf: a #GdkPixbuf
322  * @src_x: X coord in @src_pixbuf
323  * @src_y: Y coord in @src_pixbuf
324  * @width: width of region in @src_pixbuf
325  * @height: height of region in @src_pixbuf
326  * 
327  * Creates a new pixbuf which represents a sub-region of
328  * @src_pixbuf. The new pixbuf shares its pixels with the
329  * original pixbuf, so writing to one affects both.
330  * The new pixbuf holds a reference to @src_pixbuf, so
331  * @src_pixbuf will not be finalized until the new pixbuf
332  * is finalized.
333  * 
334  * Return value: a new pixbuf 
335  **/
336 GdkPixbuf*
337 gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
338                           int        src_x,
339                           int        src_y,
340                           int        width,
341                           int        height)
342 {
343         guchar *pixels;
344         GdkPixbuf *sub;
345
346         g_return_val_if_fail (GDK_IS_PIXBUF (src_pixbuf), NULL);
347         g_return_val_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width, NULL);
348         g_return_val_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height, NULL);
349
350         pixels = (gdk_pixbuf_get_pixels (src_pixbuf)
351                   + src_y * src_pixbuf->rowstride
352                   + src_x * src_pixbuf->n_channels);
353
354         sub = gdk_pixbuf_new_from_data (pixels,
355                                         src_pixbuf->colorspace,
356                                         src_pixbuf->has_alpha,
357                                         src_pixbuf->bits_per_sample,
358                                         width, height,
359                                         src_pixbuf->rowstride,
360                                         NULL, NULL);
361
362         /* Keep a reference to src_pixbuf */
363         g_object_ref (src_pixbuf);
364   
365         g_object_set_qdata_full (G_OBJECT (sub),
366                                  g_quark_from_static_string ("gdk-pixbuf-subpixbuf-src"),
367                                  src_pixbuf,
368                                  (GDestroyNotify) g_object_unref);
369
370         return sub;
371 }
372
373 \f
374
375 /* Accessors */
376
377 /**
378  * gdk_pixbuf_get_colorspace:
379  * @pixbuf: A pixbuf.
380  *
381  * Queries the color space of a pixbuf.
382  *
383  * Return value: Color space.
384  **/
385 GdkColorspace
386 gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf)
387 {
388         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), GDK_COLORSPACE_RGB);
389
390         return pixbuf->colorspace;
391 }
392
393 /**
394  * gdk_pixbuf_get_n_channels:
395  * @pixbuf: A pixbuf.
396  *
397  * Queries the number of channels of a pixbuf.
398  *
399  * Return value: Number of channels.
400  **/
401 int
402 gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
403 {
404         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
405
406         return pixbuf->n_channels;
407 }
408
409 /**
410  * gdk_pixbuf_get_has_alpha:
411  * @pixbuf: A pixbuf.
412  *
413  * Queries whether a pixbuf has an alpha channel (opacity information).
414  *
415  * Return value: %TRUE if it has an alpha channel, %FALSE otherwise.
416  **/
417 gboolean
418 gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
419 {
420         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
421
422         return pixbuf->has_alpha ? TRUE : FALSE;
423 }
424
425 /**
426  * gdk_pixbuf_get_bits_per_sample:
427  * @pixbuf: A pixbuf.
428  *
429  * Queries the number of bits per color sample in a pixbuf.
430  *
431  * Return value: Number of bits per color sample.
432  **/
433 int
434 gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf)
435 {
436         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
437
438         return pixbuf->bits_per_sample;
439 }
440
441 /**
442  * gdk_pixbuf_get_pixels:
443  * @pixbuf: A pixbuf.
444  *
445  * Queries a pointer to the pixel data of a pixbuf.
446  *
447  * Return value: A pointer to the pixbuf's pixel data.  Please see <xref linkend="image-data"/>
448  * for information about how the pixel data is stored in
449  * memory.
450  **/
451 guchar *
452 gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
453 {
454         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
455
456         return pixbuf->pixels;
457 }
458
459 /**
460  * gdk_pixbuf_get_width:
461  * @pixbuf: A pixbuf.
462  *
463  * Queries the width of a pixbuf.
464  *
465  * Return value: Width in pixels.
466  **/
467 int
468 gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
469 {
470         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
471
472         return pixbuf->width;
473 }
474
475 /**
476  * gdk_pixbuf_get_height:
477  * @pixbuf: A pixbuf.
478  *
479  * Queries the height of a pixbuf.
480  *
481  * Return value: Height in pixels.
482  **/
483 int
484 gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
485 {
486         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
487
488         return pixbuf->height;
489 }
490
491 /**
492  * gdk_pixbuf_get_rowstride:
493  * @pixbuf: A pixbuf.
494  *
495  * Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
496  * and the start of the next row.
497  *
498  * Return value: Distance between row starts.
499  **/
500 int
501 gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf)
502 {
503         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
504
505         return pixbuf->rowstride;
506 }
507
508 \f
509
510 /* General initialization hooks */
511 const guint gdk_pixbuf_major_version = GDK_PIXBUF_MAJOR;
512 const guint gdk_pixbuf_minor_version = GDK_PIXBUF_MINOR;
513 const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
514
515 const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
516
517 /* Error quark */
518 GQuark
519 gdk_pixbuf_error_quark (void)
520 {
521   return g_quark_from_static_string ("gdk-pixbuf-error-quark");
522 }
523
524 /**
525  * gdk_pixbuf_fill:
526  * @pixbuf: a #GdkPixbuf
527  * @pixel: RGBA pixel to clear to
528  *         (0xffffffff is opaque white, 0x00000000 transparent black)
529  *
530  * Clears a pixbuf to the given RGBA value, converting the RGBA value into
531  * the pixbuf's pixel format. The alpha will be ignored if the pixbuf
532  * doesn't have an alpha channel.
533  * 
534  **/
535 void
536 gdk_pixbuf_fill (GdkPixbuf *pixbuf,
537                  guint32    pixel)
538 {
539         guchar *pixels;
540         guint r, g, b, a;
541         guchar *p;
542         guint w, h;
543
544         g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
545
546         if (pixbuf->width == 0 || pixbuf->height == 0)
547                 return;
548
549         pixels = pixbuf->pixels;
550
551         r = (pixel & 0xff000000) >> 24;
552         g = (pixel & 0x00ff0000) >> 16;
553         b = (pixel & 0x0000ff00) >> 8;
554         a = (pixel & 0x000000ff);
555
556         h = pixbuf->height;
557         
558         while (h--) {
559                 w = pixbuf->width;
560                 p = pixels;
561
562                 switch (pixbuf->n_channels) {
563                 case 3:
564                         while (w--) {
565                                 p[0] = r;
566                                 p[1] = g;
567                                 p[2] = b;
568                                 p += 3;
569                         }
570                         break;
571                 case 4:
572                         while (w--) {
573                                 p[0] = r;
574                                 p[1] = g;
575                                 p[2] = b;
576                                 p[3] = a;
577                                 p += 4;
578                         }
579                         break;
580                 default:
581                         break;
582                 }
583                 
584                 pixels += pixbuf->rowstride;
585         }
586 }
587
588 \f
589
590 /**
591  * gdk_pixbuf_get_option:
592  * @pixbuf: a #GdkPixbuf
593  * @key: a nul-terminated string.
594  * 
595  * Looks up @key in the list of options that may have been attached to the
596  * @pixbuf when it was loaded, or that may have been attached by another
597  * function using gdk_pixbuf_set_option().
598  *
599  * For instance, the ANI loader provides "Title" and "Artist" options. 
600  * The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot 
601  * options for cursor definitions. The PNG loader provides the tEXt ancillary
602  * chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
603  * return an "orientation" option string that corresponds to the embedded 
604  * TIFF/Exif orientation tag (if present).
605  * 
606  * Return value: the value associated with @key. This is a nul-terminated 
607  * string that should not be freed or %NULL if @key was not found.
608  **/
609 G_CONST_RETURN gchar *
610 gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
611                        const gchar *key)
612 {
613         gchar **options;
614         gint i;
615
616         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
617         g_return_val_if_fail (key != NULL, NULL);
618   
619         options = g_object_get_qdata (G_OBJECT (pixbuf), 
620                                       g_quark_from_static_string ("gdk_pixbuf_options"));
621         if (options) {
622                 for (i = 0; options[2*i]; i++) {
623                         if (strcmp (options[2*i], key) == 0)
624                                 return options[2*i+1];
625                 }
626         }
627         
628         return NULL;
629 }
630
631 /**
632  * gdk_pixbuf_set_option:
633  * @pixbuf: a #GdkPixbuf
634  * @key: a nul-terminated string.
635  * @value: a nul-terminated string.
636  * 
637  * Attaches a key/value pair as an option to a #GdkPixbuf. If %key already
638  * exists in the list of options attached to @pixbuf, the new value is 
639  * ignored and %FALSE is returned.
640  *
641  * Return value: %TRUE on success.
642  *
643  * Since: 2.2
644  **/
645 gboolean
646 gdk_pixbuf_set_option (GdkPixbuf   *pixbuf,
647                        const gchar *key,
648                        const gchar *value)
649 {
650         GQuark  quark;
651         gchar **options;
652         gint n = 0;
653  
654         g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
655         g_return_val_if_fail (key != NULL, FALSE);
656         g_return_val_if_fail (value != NULL, FALSE);
657
658         quark = g_quark_from_static_string ("gdk_pixbuf_options");
659
660         options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
661
662         if (options) {
663                 for (n = 0; options[2*n]; n++) {
664                         if (strcmp (options[2*n], key) == 0)
665                                 return FALSE;
666                 }
667
668                 g_object_steal_qdata (G_OBJECT (pixbuf), quark);
669                 options = g_renew (gchar *, options, 2*(n+1) + 1);
670         } else {
671                 options = g_new (gchar *, 3);
672         }
673         
674         options[2*n]   = g_strdup (key);
675         options[2*n+1] = g_strdup (value);
676         options[2*n+2] = NULL;
677
678         g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
679                                  options, (GDestroyNotify) g_strfreev);
680         
681         return TRUE;
682 }
683
684 static void
685 gdk_pixbuf_set_property (GObject         *object,
686                          guint            prop_id,
687                          const GValue    *value,
688                          GParamSpec      *pspec)
689 {
690   GdkPixbuf *pixbuf = GDK_PIXBUF (object);
691
692   switch (prop_id)
693           {
694           case PROP_COLORSPACE:
695                   pixbuf->colorspace = g_value_get_enum (value);
696                   break;
697           case PROP_N_CHANNELS:
698                   pixbuf->n_channels = g_value_get_int (value);
699                   break;
700           case PROP_HAS_ALPHA:
701                   pixbuf->has_alpha = g_value_get_boolean (value);
702                   break;
703           case PROP_BITS_PER_SAMPLE:
704                   pixbuf->bits_per_sample = g_value_get_int (value);
705                   break;
706           case PROP_WIDTH:
707                   pixbuf->width = g_value_get_int (value);
708                   break;
709           case PROP_HEIGHT:
710                   pixbuf->height = g_value_get_int (value);
711                   break;
712           case PROP_ROWSTRIDE:
713                   pixbuf->rowstride = g_value_get_int (value);
714                   break;
715           case PROP_PIXELS:
716                   pixbuf->pixels = (guchar *) g_value_get_pointer (value);
717                   break;
718           default:
719                   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
720                   break;
721           }
722 }
723
724 static void
725 gdk_pixbuf_get_property (GObject         *object,
726                          guint            prop_id,
727                          GValue          *value,
728                          GParamSpec      *pspec)
729 {
730   GdkPixbuf *pixbuf = GDK_PIXBUF (object);
731   
732   switch (prop_id)
733           {
734           case PROP_COLORSPACE:
735                   g_value_set_enum (value, gdk_pixbuf_get_colorspace (pixbuf));
736                   break;
737           case PROP_N_CHANNELS:
738                   g_value_set_int (value, gdk_pixbuf_get_n_channels (pixbuf));
739                   break;
740           case PROP_HAS_ALPHA:
741                   g_value_set_boolean (value, gdk_pixbuf_get_has_alpha (pixbuf));
742                   break;
743           case PROP_BITS_PER_SAMPLE:
744                   g_value_set_int (value, gdk_pixbuf_get_bits_per_sample (pixbuf));
745                   break;
746           case PROP_WIDTH:
747                   g_value_set_int (value, gdk_pixbuf_get_width (pixbuf));
748                   break;
749           case PROP_HEIGHT:
750                   g_value_set_int (value, gdk_pixbuf_get_height (pixbuf));
751                   break;
752           case PROP_ROWSTRIDE:
753                   g_value_set_int (value, gdk_pixbuf_get_rowstride (pixbuf));
754                   break;
755           case PROP_PIXELS:
756                   g_value_set_pointer (value, gdk_pixbuf_get_pixels (pixbuf));
757                   break;
758           default:
759                   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
760                   break;
761           }
762 }
763
764 #define __GDK_PIXBUF_C__
765 #include "gdk-pixbuf-aliasdef.c"