Gimp.cairo_surface_get_buffer
Description: Reference for Gimp.cairo_surface_get_buffer

### Function

# Gimpcairo_surface_get_buffer

since: 3.0.8

#### Declaration [src]

    GeglBuffer*
    gimp_cairo_surface_get_buffer (
      cairo_surface_t* surface,
      const Babl* format,
      gboolean sync_back
    )

#### Description [src]

This function returns a `GeglBuffer` containing `surface`‘s pixels. It must only be called on image surfaces, calling it on other surface types is an error.

If `format` is set, the returned buffer will use it. It has to map with `surface` Cairo format. If unset, the buffer format will be determined from `surface`. The main difference is that automatically determined format has sRGB space and TRC by default.

If you want the changes to the returned buffer to be synced back to `surface` data, set `sync_back` to `TRUE`. If you don’t need this and only want a copy of `surface` at a given time, `FALSE` will be less costly.

When `sync_back` is `TRUE`, `gegl_buffer_freeze_changed()` and `gegl_buffer_thaw_changed()` may be useful to block intermediate syncing.

Available since: 3.0.8

#### Parameters

`surface`

  Type: `cairo_surface_t`

  A Cairo surface.

  The data is owned by the caller of the function.

`format`

  Type: `Babl`

  A Babl format.

  The data is owned by the caller of the function.

`sync_back`

  Type: `gboolean`

  Whether changes on the returned buffer should be synced back to `surface`.

#### Return value

Type: `GeglBuffer`

A `GeglBuffer`.

The caller of the function takes ownership of the data, and is responsible for freeing it.