31 #ifndef PNGPP_READER_HPP_INCLUDED 32 #define PNGPP_READER_HPP_INCLUDED 64 template<
class istream >
74 :
io_base(png_create_read_struct(PNG_LIBPNG_VER_STRING,
79 png_set_read_fn(
m_png, & stream, read_data);
84 png_destroy_read_struct(&
m_png,
95 if (setjmp(png_jmpbuf(
m_png)))
110 if (setjmp(png_jmpbuf(
m_png)))
122 if (setjmp(png_jmpbuf(
m_png)))
126 png_read_row(
m_png, bytes, 0);
134 if (setjmp(png_jmpbuf(
m_png)))
147 static void read_data(png_struct*
png,
byte* data, png_size_t length)
152 istream* stream =
reinterpret_cast< istream*
>(png_get_io_ptr(png));
155 stream->read(reinterpret_cast< char* >(data), length);
161 catch (std::exception
const&
error)
167 assert(!
"read_data: caught something wrong");
168 rd->
set_error(
"read_data: caught something wrong");
179 #endif // PNGPP_READER_HPP_INCLUDED end_info m_end_info
Definition: io_base.hpp:461
png_info * get_png_info() const
Definition: info_base.hpp:59
Base class for PNG reader/writer classes.
Definition: io_base.hpp:62
void read_info()
Reads info about PNG image.
Definition: reader.hpp:108
bool is_error() const
Definition: io_base.hpp:442
void read()
Definition: info.hpp:55
info m_info
Definition: io_base.hpp:460
void update()
Definition: info.hpp:160
The PNG reader class template. This is the low-level reading interface–use image class or consumer c...
Definition: reader.hpp:65
std::string m_error
Definition: io_base.hpp:462
void raise_error()
Definition: io_base.hpp:447
void read_row(byte *bytes)
Reads a row of image data at a time.
Definition: reader.hpp:120
void read_end_info()
Reads ending info about PNG image.
Definition: reader.hpp:132
png_struct * m_png
Definition: io_base.hpp:459
png_info ** get_png_info_ptr()
Definition: info_base.hpp:64
png_byte byte
Definition: types.hpp:39
void read_png()
Reads the whole PNG data stream into memory. Not particularly useful.
Definition: reader.hpp:93
void update_info()
Definition: reader.hpp:141
void reset_error()
Definition: io_base.hpp:430
reader(istream &stream)
Constructs a reader prepared to read PNG image from a stream.
Definition: reader.hpp:73
~reader()
Definition: reader.hpp:82
void read()
Definition: end_info.hpp:59
Exception class to represent runtime errors related to png++ operation.
Definition: error.hpp:57
void set_error(char const *message)
Definition: io_base.hpp:424