package cairo2
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Cairo.PNG
Source
The PNG functions allow reading PNG images into image surfaces, and writing any surface to a PNG file.
To create a new PNG file, start by creating an image surface, providing its format
(see Image.format
) and dimensions w
×h
with let surface = Cairo.Image.create format w h
. From this you can create a Cairo context to do your drawing: let cr = Cairo.create surface
. Then, when you are done, call Cairo.PNG.write surface fname
to write the surface to the PNG file fname
.
create filename
creates a new image surface and initializes the contents to the given PNG file.
Creates a new image surface from PNG data read incrementally via the input
function. The input s l
function receives a string s
whose first l
bytes must be filled with PNG data. Any exception raised by input
is considered as a read error.
write surface filename
writes the contents of surface
to a new file filename
as a PNG image.