[cairo] How to get PNG Stream Size before Writing the stream
Tony Rich
aerich at fastmail.com.au
Fri Jul 16 20:52:16 PDT 2010
I am using the cairo_surface_write_to_png_stream() function to
write a PNG stream to an allocated buffer - usually successfully.
The result will be an exact number of bytes, literally
representing
the generated PNG image in memory, as if it is a file. I can then
write this stream of bytes to a database or elsewhere.
Problem is, the custom write function does not know the actual
size of the buffer to allocate in advance, which of course would
be the size of the PNG stream AFTER it has been created from
the current cairo surface and context.
As a result, if I don't allocate enough space for the final image
stream, the write function returns an error.
i.e, I have to guess a sufficiently large buffer size - which
does not
lend itself to a flexible program.
So how do we find the number of bytes that an image surface will
contain, BEFORE writing it to a PNG stream??
This would round off a spectacular vector drawing API.
Thanks in advance if anyone can help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100717/bd9c1fc1/attachment.htm>
More information about the cairo
mailing list