1 <!-- ##### SECTION Title ##### -->
2 The GdkPixbuf Structure
4 <!-- ##### SECTION Short_Description ##### -->
5 Information that describes an image.
7 <!-- ##### SECTION Long_Description ##### -->
10 The <structname>GdkPixbuf</structname> structure contains
11 information that describes an image in memory.
14 <section id="image-data">
15 <title>Image Data</title>
18 Image data in a pixbuf is stored in memory in uncompressed,
19 packed format. Rows in the image are stored top to bottom, and
20 in each row pixels are stored from left to right. There may be
21 padding at the end of a row. The "rowstride" value of a pixbuf,
22 as returned by gdk_pixbuf_get_rowstride(), indicates the number
23 of bytes between rows.
26 <example id="put-pixel">
27 <title>put_pixel(<!-- -->) example</title>
30 The following code illustrates a simple put_pixel(<!-- -->)
31 function for RGB pixbufs with 8 bits per channel with an alpha
32 channel. It is not included in the gdk-pixbuf library for
33 performance reasons; rather than making several function calls
34 for each pixel, your own code can take shortcuts.
39 put_pixel (GdkPixbuf *pixbuf, int x, int y, guchar red, guchar green, guchar blue, guchar alpha)
41 int width, height, rowstride, n_channels;
44 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
46 g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
47 g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
48 g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
49 g_assert (n_channels == 4);
51 width = gdk_pixbuf_get_width (pixbuf);
52 height = gdk_pixbuf_get_height (pixbuf);
54 g_assert (x >= 0 && x < width);
55 g_assert (y >= 0 && y < height);
57 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
58 pixels = gdk_pixbuf_get_pixels (pixbuf);
60 p = pixels + y * rowstride + x * n_channels;
69 This function will not work for pixbufs with images that are
70 other than 8 bits per sample or channel, but it will work for
71 most of the pixbufs that GTK+ uses.
77 If you are doing memcpy() of raw pixbuf data, note that the
78 last row in the pixbuf may not be as wide as the full
79 rowstride, but rather just as wide as the pixel data needs to
80 be. That is, it is unsafe to do <literal>memcpy (dest,
81 pixels, rowstride * height)</literal> to copy a whole pixbuf.
82 Use gdk_pixbuf_copy() instead, or compute the width in bytes
83 of the last row as <literal>width * ((n_channels *
84 bits_per_sample + 7) / 8)</literal>.
89 <!-- ##### SECTION See_Also ##### -->
93 <!-- ##### SECTION Stability_Level ##### -->
96 <!-- ##### SECTION Image ##### -->
99 <!-- ##### ENUM GdkPixbufError ##### -->
101 An error code in the #GDK_PIXBUF_ERROR domain. Many &gdk-pixbuf;
102 operations can cause errors in this domain, or in the #G_FILE_ERROR
106 @GDK_PIXBUF_ERROR_CORRUPT_IMAGE: An image file was broken somehow.
107 @GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY: Not enough memory.
108 @GDK_PIXBUF_ERROR_BAD_OPTION: A bad option was passed to a pixbuf save module.
109 @GDK_PIXBUF_ERROR_UNKNOWN_TYPE: Unknown image type.
110 @GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: Don't know how to perform the
111 given operation on the type of image at hand.
112 @GDK_PIXBUF_ERROR_FAILED: Generic failure code, something went wrong.
114 <!-- ##### MACRO GDK_PIXBUF_ERROR ##### -->
116 Error domain used for pixbuf operations. Indicates that the error code
117 will be in the #GdkPixbufError enumeration. See #GError for
118 information on error domains and error codes.
123 <!-- ##### ENUM GdkColorspace ##### -->
125 This enumeration defines the color spaces that are supported by
126 the &gdk-pixbuf; library. Currently only RGB is supported.
129 @GDK_COLORSPACE_RGB: Indicates a red/green/blue additive color space.
131 <!-- ##### ENUM GdkPixbufAlphaMode ##### -->
133 This function can create a
134 bilevel clipping mask (black and white) and use it while painting
135 the image. In the future, when the X Window System gets an alpha
136 channel extension, it will be possible to do full alpha
137 compositing onto arbitrary drawables. For now both cases fall
138 back to a bilevel clipping mask.
141 @GDK_PIXBUF_ALPHA_BILEVEL: A bilevel clipping mask (black and white)
142 will be created and used to draw the image. Pixels below 0.5 opacity
143 will be considered fully transparent, and all others will be
144 considered fully opaque.
145 @GDK_PIXBUF_ALPHA_FULL: For now falls back to #GDK_PIXBUF_ALPHA_BILEVEL.
146 In the future it will do full alpha compositing.
148 <!-- ##### STRUCT GdkPixbuf ##### -->
150 This is the main structure in the &gdk-pixbuf; library. It is
151 used to represent images. It contains information about the
152 image's pixel data, its color space, bits per sample, width and
153 height, and the rowstride (the number of bytes between the start of
154 one row and the start of the next).
158 <!-- ##### ARG GdkPixbuf:bits-per-sample ##### -->
163 <!-- ##### ARG GdkPixbuf:colorspace ##### -->
168 <!-- ##### ARG GdkPixbuf:has-alpha ##### -->
173 <!-- ##### ARG GdkPixbuf:height ##### -->
178 <!-- ##### ARG GdkPixbuf:n-channels ##### -->
183 <!-- ##### ARG GdkPixbuf:pixels ##### -->
188 <!-- ##### ARG GdkPixbuf:rowstride ##### -->
193 <!-- ##### ARG GdkPixbuf:width ##### -->
198 <!-- ##### FUNCTION gdk_pixbuf_get_colorspace ##### -->
207 <!-- ##### FUNCTION gdk_pixbuf_get_n_channels ##### -->
216 <!-- ##### FUNCTION gdk_pixbuf_get_has_alpha ##### -->
225 <!-- ##### FUNCTION gdk_pixbuf_get_bits_per_sample ##### -->
234 <!-- ##### FUNCTION gdk_pixbuf_get_pixels ##### -->
243 <!-- ##### FUNCTION gdk_pixbuf_get_width ##### -->
252 <!-- ##### FUNCTION gdk_pixbuf_get_height ##### -->
261 <!-- ##### FUNCTION gdk_pixbuf_get_rowstride ##### -->
270 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
275 <!-- ##### FUNCTION gdk_pixbuf_get_option ##### -->
288 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2")