Next: PostScript Surfaces, Previous: PDF Surfaces, Up: Top [Index]
Reading and writing PNG images
The PNG functions allow reading PNG images into image surfaces, and writing any surface to a PNG file.
<char>) ⇒ (ret <cairo-surface-t >)Creates a new image surface and initializes the contents to the given PNG file.
name of PNG file to load
a new <cairo-surface-t> initialized with the contents of the PNG
file, or a "nil" surface if any error occurred. A nil surface can be
checked for with cairo_surface_status(surface) which may return one of
the following values:
‘CAIRO_STATUS_NO_MEMORY’‘CAIRO_STATUS_FILE_NOT_FOUND’‘CAI
RO_STATUS_READ_ERROR’ Alternatively, you can allow errors to propagate
through the drawing operations and check the status on the context upon
completion using cairo-status.
<cairo-surface-t>) (filename <char>) ⇒ (ret <cairo-status-t>)Writes the contents of surface to a new file filename as a PNG image.
a <cairo-surface-t> with pixel contents
the name of a file to write to
‘CAIRO_STATUS_SUCCESS’ if the PNG file was written successfully. Otherwise, ‘CAIRO_STATUS_NO_MEMORY’ if memory could not be allocated for the operation or ‘CAIRO_STATUS_SURFACE_TYPE_MISMATCH’ if the surface does not have pixel contents, or ‘CAIRO_STATUS_WRITE_ERROR’ if an I/O error occurs while attempting to write the file.