# Gimp.cairo_surface_create_buffer

    function cairo_surface_create_buffer(surface: cairo.Surface, format: Babl.Object): Gegl.Buffer {
        // Gjs wrapper for gimp_cairo_surface_create_buffer()
    }

This function returns a Gegl.Buffer which wraps 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 [class@Gegl.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.

Since 2.10

surface

  a Cairo surface

format

  a Babl format.

Returns

  a Gegl.Buffer