[cairo] pycairo and PIL

Steve Chaplin stevech1097 at yahoo.com.au
Mon Oct 10 06:14:49 PDT 2005


On Tue, 2005-10-04 at 18:22 -0500, James Evans wrote:
> > I tried the patch, and it works for surfaces created with
> >    surface = cairo.ImageSurface (format, width, height)
> > which calls the patched ImageSurface.__new__(), but does not work for
> surfaces created with other methods, for example
> >     surface = cairo.ImageSurface.create_from_png (filename)
> >     surface = cairo.ImageSurface.create_for_data (data, format, w, h, s)
> > which call
> >     PycairoSurface_FromSurface() instead of ImageSurface.__new__()
> > For these surfaces I got
> >>>> data = surface.get_data()
> > SystemError: null argument to internal routine
> > since there is no Python buffer associated with the PycairoImageSurface
> 
> This patch wasn't intended to be a final solution. I know it only works
> for cairo.ImageSurface(). I was looking for feedback on the solution
> before I implemented all possible uses. create_from_png has the added
> problem that you'd have to read the png in and create a buffer from it to
> pass to cairo_image_surface_create_for_data, duplicating functionality in
> pycairo that exists in cairo.
> 
> The feedback I've gotten from you is that you don't think this solution is
> worth pursuing. Is that correct? (Also, please see comments below)

I liked it when I first saw it, but it doesn't work for all possible
ImageSurfaces, and getting it to work if that is even possible, would
probably result in complex code. Other language bindings would also have
to work out their own different solutions to the same problem. Instead
of patching pycairo and the other language bindings I'd rather patch
cairo itself and solve the problem once for all bindings.
I opened a cairo bug report for this, so hopefully it will get looked
into and fixed eventually.
https://bugs.freedesktop.org/show_bug.cgi?id=4687
In the meantime I'll have a look at creating a cairo patch and creating
a surface.to_rgba() method using the patch.

Steve

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the cairo mailing list