Re: cairo surface from GdkPixmap



Hi Andrew,

See my tutorial at:

http://giv.sourceforge.net/gtk-image-viewer/gtkimageviewer_tutorial.html

and search for "cairo" for an example of how to draw on a pixbuf with cairo. Basically all you need to do is:

  cairo_surface_t *surface
= cairo_image_surface_create_for_data(gdk_pixbuf_get_pixels(pixbuf),
CAIRO_FORMAT_RGB24,
img_width,
img_height,
gdk_pixbuf_get_rowstride(pixbuf));
Beware cairo's and gdkpixbuf's ideas about r,g, and b, are swapped so you will need to swap the blue and the red channels when painting.

Regards,
Dov

2009/6/14 Andrew Cowie <andrew operationaldynamics com>
On Sat, 2009-06-13 at 19:50 -0700, Michiel de Hoon wrote:
> I am looking for a way to obtain a Cairo surface from a GdkPixmap.

You're probably looking for gdk_cairo_create() or
gdk_cairo_set_source_pixmap(), depending on what exactly you're up to.
http://library.gnome.org/devel/gdk/stable/gdk-Cairo-Interaction.html

As is compulsory on this list :) I note in passing that it turns out
that this [poorly-named] list is the one for discussion about _hacking_
on GTK. Questions about _developing_ with the library are best directed
to gtk-list.

AfC
Sydney


_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list




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