Module Cairo.PNG

module PNG: sig .. end
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 Cairo.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 -> Cairo.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) -> Cairo.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 : Cairo.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 : Cairo.Surface.t -> output:(string -> unit) -> unit
Writes the image surface using the output function.