imageSurfaceCreateFromPng

Creates a new image surface and initializes the contents to the given PNG file.

imageSurfaceCreateFromPng
(
string filename
)

Parameters

filename string

name of PNG file to load. On Windows this filename is encoded in UTF-8.

Return Value

Type: cairo.surface.Surface

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.types.Status.NoMemory

cairo.types.Status.FileNotFound

cairo.types.Status.ReadError

cairo.types.Status.PngError

Alternatively, you can allow errors to propagate through the drawing operations and check the status on the context upon completion using cairo.context.Context.status.