package cairo2
Library
Module
Module type
Parameter
Class
Class type
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
.
val create : string -> Surface.t
create filename
creates a new image surface and initializes the contents to the given PNG file.
val create_from_stream : input:(string -> int -> unit) -> Surface.t
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.
val write : Surface.t -> string -> unit
write surface filename
writes the contents of surface
to a new file filename
as a PNG image.
val write_to_stream : Surface.t -> output:(string -> unit) -> unit
Writes the image surface using the output
function.