[cairo] Implementing cairo_read_func_t/cairo_write_func_t properly
bf at abenteuerland.at
Wed Dec 30 06:27:13 PST 2015
According to the documentation (http://www.cairographics.org/manual/cairo-PNG-Support.html#cairo-read-func-t) the cairo_read_func_t shall return either
CAIRO_STATUS_SUCCESS if everything is ok or CAIRO_STATUS_READ_ERROR in case of
Unfortunately, in reality there is a 3rd case: truncated, i.e. EOF reached.
The problem now is that if EOF (i.e. a truncated read happens) occurs and I
would return STATUS_SUCCESS, then the calling function can never detect that
EOF occured thus looping forever. In the other case when I would return
STATUS_READ_ERROR, then the calling function cannot detect how many bytes then
actually have been read except in the case that I read 1 byte after the other.
Is there any suggestion on how to implement a such stream functions properly?
PS: I'm trying to implement cairo_image_surface_create_from_jpeg_stream() with
the same prototype as cairo_image_surface_create_from_png_stream() and not
willing to call the read function byte-by-byte.
More information about the cairo