```{index} single: create_from_png_stream (Cairo::ImageSurface) ``` ```{index} single: Cairo::ImageSurface::create_from_png_stream ``` # create_from_png_stream Reads a PNG by asking a callback of yours for successive chunks of it, and returns the result as a `Cairo::ImageSurface`. my $surface = Cairo::ImageSurface->create_from_png_stream(sub { my ($data, $length) = @_; read($fh, my $buf, $length); return $buf; }); The callback is called with two arguments - the optional `$data` value you passed after it, and the number of bytes wanted - and must RETURN the bytes it read. To report a failure, die with a cairo status name such as `'read-error'`; the surface then comes back with that status rather than the call dying. The callback is only used during construction and is not retained afterwards. Dies if the cairo installed on this machine was built without PNG support. Wraps `cairo_image_surface_create_from_png_stream`.