Draw gegl image to cairo surface?
On 05/15/2010 01:41 AM, Stuart Axon wrote:
Hi,
I read somewhere that gegl can wrap a cairo surface....
Any idea how in python/vala/c#/some high level language I can use gegl to load an image, and draw on the cairo surface ?
This is how you'd do it in C, so now you just has to make sure you can
do the same with some binding:
#include
#include
int main (int argc, char **argv)
{
GeglNode *load;
GeglRectangle size;
cairo_surface_t *image;
gegl_init (&argc, &argv);
load = gegl_node_new ();
gegl_node_set (load,
"operation", "gegl:load",
"path", "/tmp/test.png",
NULL);
size = gegl_node_get_bounding_box (load);
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
size.width,
size.height);
gegl_node_blit (load,
1.0 /*scale*/,
&size,
babl_format ("R'G'B'A u8"),
cairo_image_surface_get_data (image),
GEGL_AUTO_ROWSTRIDE,
GEGL_BLIT_DEFAULT);
cairo_surface_write_to_png (image, "/tmp/output.png");
return 0;
}
/ Martin