[cairo] cairo_surface_t to GdkPixbuf conversion

Carl Worth cworth at cworth.org
Mon Oct 20 14:06:32 PDT 2008

On Mon, 2008-10-20 at 15:48 +0530, zaheer ahmad wrote:

> Thanks for the quick response. I tried the api
> gdk_pixbuf_get_from_drawable( however it does not seem to work with a
> cairo_surface_t, is cairo_surface_t a GdkDrawable i think its not?

No, it is not.

Let's add a couple of variables to the previously-offered pseudo-code to
see if things become more clear:

GdkPixmap *pixmap = gdk_pixmap_new(NULL, width, height, depth);
cairo_t *cr = gdk_cairo_create(pixmap);
cairo_set_source_surface(cr, surface);
GdkPixbuf *pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL,
		0, 0, 0, 0, width, height);

Of course, none of that code is compiled at all, and I'm sure it's
missing some ugly typecasting macros, (GDK_DRAWABLE(pixmap) perhaps?).
But hopefully it's helpful,

-Carl (happy that the cairo functions all have relatively few

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20081020/b4c3f0ae/attachment.pgp 

More information about the cairo mailing list