On 2010.03.02 10:59:05 +0100, Osmo Maatta wrote:
> I have a program that needs to draw circles and other elements on a 
> gdk.Pixbuf image.
> 
> The current code works well but when creating a Cairo-surface from 
> pixbuf, the  gtk.gdk.Pixbuf.get_pixels_array() function reports that 
> it's deprecated and should be avoided.

> 1) What is the best way to draw onto gdk.Pixbuf? (most likely using 
> Cairo, other means also welcomed)

I think Cairo is the best way.  I used to use PIL, but switching to
Cairo let me remove a dependency, and use the same API for drawing
to the screen and drawing to image files.

> 2) If  the gtk.gdk.Pixbuf.get_pixels_array() or its internals are 
> deprecated, then what will replace it?

I don't see a direct replacement.  One way to do it is Pixbuf.save() to
a PNG, then cairo.ImageSurface.create_from_png().  I don't know if
that's significantly less efficient than Pixbuf.get_pixels_array().  It
does avoid depending on NumPy.

There might be useful information about this in the version control logs
or bug tracker, if you're willing to dig for it.

-- 
David Ripton    [email protected]
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to