### Function

# Gdk.pixbuf_get_from_surface

#### Declaration [src]

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

#### Description [src]

Transfers image data from a `cairo_surface_t` and converts it to a `GdkPixbuf`.

This allows you to efficiently read individual pixels from cairo surfaces.

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` | `cairo_surface_t*`
| surface to copy from
| Ownership is not transferred to the callee
`src_x` | `int`
| Source X coordinate within `surface`
`src_y` | `int`
| Source Y coordinate within `surface`
`width` | `int`
| Width in pixels of region to get
`height` | `int`
| Height in pixels of region to get

#### Return value

Returns: `Gdkixbuf.Pixbuf`
A newly-created pixbuf with a reference count of 1, or `NULL` on error
Ownership of the data is transferred to the caller
Can be `NULL`