Pixbufs

Pixbufs — Functions for obtaining pixbufs

Functions

GdkPixbuf * gdk_pixbuf_get_from_window ()
GdkPixbuf * gdk_pixbuf_get_from_surface ()

Includes

#include <gdk/gdk.h>

Description

Pixbufs are client-side images. For details on how to create and manipulate pixbufs, see the GdkPixbuf API documentation.

The functions described here allow to obtain pixbufs from GdkWindows and cairo surfaces.

Functions

gdk_pixbuf_get_from_window ()

GdkPixbuf *
gdk_pixbuf_get_from_window (GdkWindow *window,
                            gint src_x,
                            gint src_y,
                            gint width,
                            gint height);

Transfers image data from a GdkWindow and converts it to an RGB(A) representation inside a GdkPixbuf.

In other words, copies image data from a server-side drawable to a client-side RGB(A) buffer. This allows you to efficiently read individual pixels on the client side.

This function will create an RGB pixbuf with 8 bits per channel with the size specified by the width and height arguments scaled by the scale factor of window . The pixbuf will contain an alpha channel if the window contains one.

If the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf. The contents of portions of the pixbuf corresponding to the offscreen region are undefined.

If the window you’re obtaining data from is partially obscured by other windows, then the contents of the pixbuf areas corresponding to the obscured regions are undefined.

If the window is not mapped (typically because it’s iconified/minimized or not on the current workspace), then NULL will be returned.

If memory can’t be allocated for the return value, NULL will be returned instead.

In short, there are several ways this function can fail, and if it fails it returns NULL; so check the return value.

You should rarely, if ever, need to call this function.

Parameters

window

Source window

 

src_x

Source X coordinate within window

 

src_y

Source Y coordinate within window

 

width

Width in pixels of region to get

 

height

Height in pixels of region to get

 

Returns

A newly-created pixbuf with a reference count of 1, or NULL on error.

[nullable][transfer full]


gdk_pixbuf_get_from_surface ()

GdkPixbuf *
gdk_pixbuf_get_from_surface (cairo_surface_t *surface,
                             gint src_x,
                             gint src_y,
                             gint width,
                             gint height);

Transfers image data from a cairo_surface_t and converts it to an RGB(A) representation inside a GdkPixbuf. This allows you to efficiently read individual pixels from cairo surfaces. For GdkWindows, use gdk_pixbuf_get_from_window() instead.

This function will create an RGB pixbuf with 8 bits per channel. The pixbuf will contain an alpha channel if the surface contains one.

Parameters

surface

surface to copy from

 

src_x

Source X coordinate within surface

 

src_y

Source Y coordinate within surface

 

width

Width in pixels of region to get

 

height

Height in pixels of region to get

 

Returns

A newly-created pixbuf with a reference count of 1, or NULL on error.

[nullable][transfer full]