[cairo] cairocffi and GDK-PixBuf for decoding JPEG and other image formats

Simon Sapin simon.sapin at exyr.org
Tue Feb 26 07:32:29 PST 2013

Le 26/02/2013 15:33, Dominic Lachowicz a écrit :
> Hi Simon,
> FYI - GdkPixbuf has an equivalent function (set_source_pixbuf) that
> can do this too.
> http://www.pygtk.org/docs/pygtk/class-gdkcairocontext.html#method-gdkcairocontext--set-source-pixbuf

This function is not actually part of GDK-PixBuf (which can be installed 
independently of GTK, these days.) cairocffi uses when available, but 
has fallback methods otherwise. (I don’t really like installing all of 
GTK on servers.)

Even with set_source_pixbuf, when all you want is an ImageSurface for 
the image you need to create a temporary surface, a temporary context, 
call set_source_pixbuf, then get_source to get a surface pattern and 
then get_surface to get the surface. Oh, and by the way, get_surface is 
buggy (segfaults) in this case with old py2cairo versions.

cairocffi hides all of this away in a simple function.

Simon Sapin

More information about the cairo mailing list