PngReader Class Reference

#include <Pt/Gfx/PngReader.h>

Reader for PNG images.

Public Member Functions

 PngReader ()
 Default Constructor.
 
 PngReader (std::istream &is, Image &image)
 Construct with target stream and image.
 
 ~PngReader ()
 Destructor.
 
void attach (std::istream &is, Image &image)
 Attach to target stream and image.
 
void detach ()
 Detach from target stream.
 
void reset ()
 Reset to begin new decompression.
 
Imageadvance (std::streamsize importSize=0)
 Reads image data from the target stream. More...
 
Imageget ()
 Reads the whole image from the stream.
 

Member Function Documentation

◆ advance()

Image* advance ( std::streamsize  importSize = 0)

Consumes bytes currently available in the stream buffer and feeds them to the PNG decoder.

When importSize is 0 (default), only bytes already available via in_avail() are consumed (non-blocking, suitable for event-loop use). When importSize is greater than 0, up to that many bytes are read from the underlying stream via sgetn(), which may block until data arrives (suitable for file or thread use).

Returns
Pointer to the completed Image once all PNG data has been decoded, nullptr when more data is needed.