## The GdkPixbuf Structure

The GdkPixbuf Structure — Information that describes an image.

## Synopsis

    #include <gdk-pixbuf/gdk-pixbuf.h>

    enum        GdkPixbufError;
    #define     GDK_PIXBUF_ERROR
    enum        GdkColorspace;
    enum        GdkPixbufAlphaMode;
    struct      GdkPixbuf;
    GdkColorspace gdk_pixbuf_get_colorspace     (const GdkPixbuf *pixbuf);
    int         gdk_pixbuf_get_n_channels       (const GdkPixbuf *pixbuf);
    gboolean    gdk_pixbuf_get_has_alpha        (const GdkPixbuf *pixbuf);
    int         gdk_pixbuf_get_bits_per_sample  (const GdkPixbuf *pixbuf);
    guchar*     gdk_pixbuf_get_pixels           (const GdkPixbuf *pixbuf);
    int         gdk_pixbuf_get_width            (const GdkPixbuf *pixbuf);
    int         gdk_pixbuf_get_height           (const GdkPixbuf *pixbuf);
    int         gdk_pixbuf_get_rowstride        (const GdkPixbuf *pixbuf);
    G_CONST_RETURN gchar* gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
                                                 const gchar *key);

## Object Hierarchy

      GObject
       +----GdkPixbuf

## Description

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

## Details

### enum GdkPixbufError

    typedef enum {
            /* image data hosed */
            GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
            /* no mem to load image */
            GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
            /* bad option passed to save routine */
            GDK_PIXBUF_ERROR_BAD_OPTION,
            /* unsupported image type (sort of an ENOSYS) */
            GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
            /* unsupported operation (load, save) for image type */
            GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
            GDK_PIXBUF_ERROR_FAILED
    } GdkPixbufError;

An error code in the GDK_PIXBUF_ERROR domain. Many gdk-pixbuf operations can cause errors in this domain, or in the G_FILE_ERROR domain.

`GDK_PIXBUF_ERROR_CORRUPT_IMAGE` | An image file was broken somehow.
`GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY` | Not enough memory.
`GDK_PIXBUF_ERROR_BAD_OPTION` | A bad option was passed to a pixbuf save module.
`GDK_PIXBUF_ERROR_UNKNOWN_TYPE` | Unknown image type.
`GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION` | Don't know how to perform the given operation on the type of image at hand.
`GDK_PIXBUF_ERROR_FAILED` | Generic failure code, something went wrong.

### GDK_PIXBUF_ERROR

    #define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()

Error domain used for pixbuf operations. Indicates that the error code will be in the GdkPixbufError enumeration. See GError for information on error domains and error codes.

### enum GdkColorspace

    typedef enum {
    	GDK_COLORSPACE_RGB
    } GdkColorspace;

This enumeration defines the color spaces that are supported by the gdk-pixbuf library. Currently only RGB is supported.

`GDK_COLORSPACE_RGB` | Indicates a red/green/blue additive color space.

### enum GdkPixbufAlphaMode

    typedef enum
    {
            GDK_PIXBUF_ALPHA_BILEVEL,
            GDK_PIXBUF_ALPHA_FULL
    } 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.
`GDK_PIXBUF_ALPHA_FULL` | For now falls back to GDK_PIXBUF_ALPHA_BILEVEL. In the future it will do full alpha compositing.

### struct GdkPixbuf

    struct 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).

### gdk_pixbuf_get_colorspace ()

    GdkColorspace gdk_pixbuf_get_colorspace     (const GdkPixbuf *pixbuf);

Queries the color space of a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | Color space.

### gdk_pixbuf_get_n_channels ()

    int         gdk_pixbuf_get_n_channels       (const GdkPixbuf *pixbuf);

Queries the number of channels of a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | Number of channels.

### gdk_pixbuf_get_has_alpha ()

    gboolean    gdk_pixbuf_get_has_alpha        (const GdkPixbuf *pixbuf);

Queries whether a pixbuf has an alpha channel (opacity information).

`pixbuf` : | A pixbuf.
Returns : | `TRUE` if it has an alpha channel, `FALSE` otherwise.

### gdk_pixbuf_get_bits_per_sample ()

    int         gdk_pixbuf_get_bits_per_sample  (const GdkPixbuf *pixbuf);

Queries the number of bits per color sample in a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | Number of bits per color sample.

### gdk_pixbuf_get_pixels ()

    guchar*     gdk_pixbuf_get_pixels           (const GdkPixbuf *pixbuf);

Queries a pointer to the pixel data of a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | A pointer to the pixbuf's pixel data.

### gdk_pixbuf_get_width ()

    int         gdk_pixbuf_get_width            (const GdkPixbuf *pixbuf);

Queries the width of a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | Width in pixels.

### gdk_pixbuf_get_height ()

    int         gdk_pixbuf_get_height           (const GdkPixbuf *pixbuf);

Queries the height of a pixbuf.

`pixbuf` : | A pixbuf.
Returns : | Height in pixels.

### gdk_pixbuf_get_rowstride ()

    int         gdk_pixbuf_get_rowstride        (const GdkPixbuf *pixbuf);

Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.

`pixbuf` : | A pixbuf.
Returns : | Distance between row starts.

### gdk_pixbuf_get_option ()

    G_CONST_RETURN gchar* gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
                                                 const gchar *key);

Looks up `key` in the list of options that may have been attached to the `pixbuf` when it was loaded.

`pixbuf` : | a GdkPixbuf
`key` : | a nul-terminated string.
Returns : | the value associated with `key`. This is a nul-terminated string that should not be freed or `NULL` if `key` was not found.