Description

The GdkPixbuf structure contains
information that describes an image in memory.

Image Data

Image data in a pixbuf is stored in memory in uncompressed,
packed format. Rows in the image are stored top to bottom, and
in each row pixels are stored from left to right. There may be
padding at the end of a row. The "rowstride" value of a pixbuf,
as returned by gdk_pixbuf_get_rowstride(), indicates the number
of bytes between rows.

Example 1. put_pixel() example

The following code illustrates a simple put_pixel()
function for RGB pixbufs with 8 bits per channel with an alpha
channel. It is not included in the gdk-pixbuf library for
performance reasons; rather than making several function calls
for each pixel, your own code can take shortcuts.

This function will not work for pixbufs with images that are
other than 8 bits per sample or channel, but it will work for
most of the pixbufs that GTK+ uses.

Note

If you are doing memcpy() of raw pixbuf data, note that the
last row in the pixbuf may not be as wide as the full
rowstride, but rather just as wide as the pixel data needs to
be. That is, it is unsafe to do memcpy (dest,
pixels, rowstride * height) to copy a whole pixbuf.
Use gdk_pixbuf_copy() instead, or compute the width in bytes
of the last row as width * ((n_channels *
bits_per_sample + 7) / 8).

enum GdkPixbufAlphaMode

These values can be passed to
gdk_pixbuf_render_to_drawable_alpha() to control how the alpha
channel of an image should be handled. This function can create a
bilevel clipping mask (black and white) and use it while painting
the image. In the future, when the X Window System gets an alpha
channel extension, it will be possible to do full alpha
compositing onto arbitrary drawables. For now both cases fall
back to a bilevel clipping mask.

GDK_PIXBUF_ALPHA_BILEVEL

A bilevel clipping mask (black and white)
will be created and used to draw the image. Pixels below 0.5 opacity
will be considered fully transparent, and all others will be
considered fully opaque.

GdkPixbuf

typedef struct _GdkPixbuf GdkPixbuf;

This is the main structure in the gdk-pixbuf library. It is
used to represent images. It contains information about the
image's pixel data, its color space, bits per sample, width and
height, and the rowstride (the number of bytes between the start of
one row and the start of the next).