[cairo] What is the closure in stream output to file based surfaces for?

Bill Spitzak spitzak at gmail.com
Tue Jul 29 10:32:41 PDT 2014


Though it could be something more complicated, usually the closure is an 
object in C++. This allows the same callback to be used for multiple 
instances:

cairo_status_t write_func(void* closure, const unsigned char* data, 
unsigned len)
{
    ((MyOutputClass*)closure)->write(data, len);
}

...
   MyOutputClass x;
   cairo_surface_write_to_png_stream (surface, write_func, (void*)(&x));
...


More information about the cairo mailing list