I’m trying to write a CGI program that will output a PNG image to stdout. I can already do this from an image file (PNG or otherwise), but now I’m using Cairo to dynamically generate some image, then output it to the browser.
The problem I’m facing is this: the way Cairo writes a surface to a PNG is using one of two functions. The first is Surface::write_to_png(string filename). This doesn’t work for me, since I’m not writing to a file, but to stdout. The second is Surface::write_to_png_stream( something-or-other write_func), as described here. I do not understand how this works, or even if this is what I want. Is there a better way to accomplish this, and if not, how do I use this abysmal function?
Thanks
As it says in the documentation, write a function to handle the writing:
Usage: