[cairo] Pycairo + PNG Output

Owen Taylor otaylor at redhat.com
Tue Oct 11 06:56:46 PDT 2005


On Tue, 2005-10-11 at 09:34 +0200, Ccx wrote:
> Hello, I'm going to use Pycairo for generating graphics on webserver.
> 
> As far as I found out, Pycairo can be set to draw either to memory in a
> raw data or to a png file, but not to a memory in png format which I need.
> 
> So I ask, is there way to do it with pycairo as it is or will it need
> some reimplementation.
> I can try to help in the second case, I have some experience with C, C++
> and Python, but not with extending Python (I've just read the guide).

In C, you can do this with cairo_surface_write_to_png_stream() ...
don't know if/how this is bound in the Python bindings. I'd think the
natural mapping would be something like:

 buffer = StringIO.StringIO()
 surface.write_to_png_stream(buffer)
 pngData = buffer.getvalue()
 buffer.close()

Regards,
					Owen

-------------- 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.freedesktop.org/archives/cairo/attachments/20051011/441db476/attachment.pgp


More information about the cairo mailing list