[cairo] Pycairo + PNG Output

James Mills prologic at shortcircuit.net.au
Tue Oct 11 23:28:43 PDT 2005


On Wed, Oct 12, 2005 at 11:43:34AM +0800, Steve Chaplin wrote:
> I dropped the 'stream' from pycairo since it seems to be a C++/Java
> term, whereas the Python documentation talks about 'file objects' and
> 'file-like objects'.
> 
> pycairo release 1.0.2 has
>    surface.write_to_png(f)
> where 'f' can be a filename or a file object.
> 
> I've just updated cvs so that 'f' can now be a filename, a file object
> or a file-like object that has a "write" method (like StringIO or
> cStringIO). It can be used like this:

Thank you. I think this is what we need :)

So I presume now with this change we can do:

import cairo
import pygame

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
import StringIO
buffer = StringIO.StringIO()
image = pygame.image.frombuffer(buffer)

...

cheers
James

-- 
--
-"Problems are Solved by Method"
-
- James Mills <prologic at shortcircuit.net.au>
- HomePage: http://shortcircuit.net.au/~prologic/
- Phone: +61732166379
- Mobile: +61404270962
- Skype: therealprologic
- MSN: prologic at shortcircuit.net.au
- ICQ: 98888663
- IRC: irc://shortcircuit.net.au#se

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


More information about the cairo mailing list