Re: Draw gegl image to cairo surface?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <gegl.h>
#include <cairo/cairo.h>

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


-- 

My GIMP Blog:
http://www.chromecode.com/
"GIMP 2.8 development still under control"
_______________________________________________
Gegl-developer mailing list
Gegl-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer

[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux