<!--/*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"/*EC*/-->
<html><head><title></title><style type="text/css"><!--body{padding:1ex;margin:0px;font-family:sans-serif;font-size:small;}a[href]{color:-moz-hyperlinktext !important;text-decoration:-moz-anchor-decoration;}blockquote{margin:0;border-left:2px solid #144fae;padding-left:1em;}blockquote blockquote{border-color:#006312;}blockquote blockquote blockquote{border-color:#540000;}--></style></head><body><div style="font-family: Arial; font-size: medium;" dir="ltr"><div>I am using the cairo_surface_write_to_png_stream() function to</div>
<div>write a PNG stream to an allocated buffer - usually successfully.</div>
<div>&nbsp;</div>
<div>The result will be an exact number of bytes, literally representing</div>
<div>the generated PNG image in memory, as if it is a file. I can then</div>
<div>write this stream of bytes to a database or elsewhere.</div>
<div>&nbsp;</div>
<div>Problem is, the custom write function does not know the actual</div>
<div>size of the buffer to allocate in advance, which of course would</div>
<div>be the size of the PNG stream AFTER it has been created from</div>
<div>the current cairo surface and context.</div>
<div>&nbsp;</div>
<div>As a result, if I don't allocate enough space for the final image</div>
<div>stream, the write function returns an error.</div>
<div>&nbsp;</div>
<div>i.e, I have to guess a sufficiently large buffer size - which does not</div>
<div>lend itself to a flexible program.</div>
<div>&nbsp;</div>
<div>So how do we find the number of bytes that an image surface will</div>
<div>contain, BEFORE writing it to a PNG stream??</div>
<div>&nbsp;</div>
<div>This would round off a spectacular vector drawing API.</div>
<div>&nbsp;</div>
<div>Thanks in advance if anyone can help.</div>
<div>&nbsp;</div></div></body></html>