PNG Support

PNG Support — Reading and writing PNG images

Synopsis




cairo_surface_t* cairo_image_surface_create_from_png
                                            (const char *filename);
cairo_status_t (*cairo_read_func_t)         (void *closure,
                                             unsigned char *data,
                                             unsigned int length);
cairo_surface_t* cairo_image_surface_create_from_png_stream
                                            (cairo_read_func_t read_func,
                                             void *closure);
cairo_status_t cairo_surface_write_to_png   (cairo_surface_t *surface,
                                             const char *filename);
cairo_status_t (*cairo_write_func_t)        (void *closure,
                                             unsigned char *data,
                                             unsigned int length);
cairo_status_t cairo_surface_write_to_png_stream
                                            (cairo_surface_t *surface,
                                             cairo_write_func_t write_func,
                                             void *closure);

Description

Details

cairo_image_surface_create_from_png ()

cairo_surface_t* cairo_image_surface_create_from_png
                                            (const char *filename);

cairo_read_func_t ()

cairo_status_t (*cairo_read_func_t)         (void *closure,
                                             unsigned char *data,
                                             unsigned int length);

cairo_read_func_t is the type of function which is called when a backend needs to read data from an intput stream. It is passed the closure which was specified by the user at the time the read function was registered, the buffer to read the data into and the length of the data in bytes. The read function should return CAIRO_STATUS_SUCCESS if all the data was successfully read, CAIRO_STATUS_READ_ERROR otherwise.

closure : the input closure
data : the buffer into which to read the data
length : the amount of data to read
Returns : the status code of the read operation

cairo_image_surface_create_from_png_stream ()

cairo_surface_t* cairo_image_surface_create_from_png_stream
                                            (cairo_read_func_t read_func,
                                             void *closure);

cairo_surface_write_to_png ()

cairo_status_t cairo_surface_write_to_png   (cairo_surface_t *surface,
                                             const char *filename);

cairo_write_func_t ()

cairo_status_t (*cairo_write_func_t)        (void *closure,
                                             unsigned char *data,
                                             unsigned int length);

cairo_write_func_t is the type of function which is called when a backend needs to write data to an output stream. It is passed the closure which was specified by the user at the time the write function was registered, the data to write and the length of the data in bytes. The write function should return CAIRO_STATUS_SUCCESS if all the data was successfully written, CAIRO_STATUS_WRITE_ERROR otherwise.

closure : the output closure
data : the buffer containing the data to write
length : the amount of data to write
Returns : the status code of the write operation

cairo_surface_write_to_png_stream ()

cairo_status_t cairo_surface_write_to_png_stream
                                            (cairo_surface_t *surface,
                                             cairo_write_func_t write_func,
                                             void *closure);