31 #ifndef PNGPP_WRITER_HPP_INCLUDED 32 #define PNGPP_WRITER_HPP_INCLUDED 65 template<
class ostream >
75 :
io_base(png_create_write_struct(PNG_LIBPNG_VER_STRING,
80 png_set_write_fn(
m_png, & stream, write_data, flush_data);
91 if (setjmp(png_jmpbuf(
m_png)))
106 if (setjmp(png_jmpbuf(
m_png)))
118 if (setjmp(png_jmpbuf(
m_png)))
122 png_write_row(
m_png, bytes);
130 if (setjmp(png_jmpbuf(
m_png)))
138 static void write_data(png_struct*
png,
byte* data, png_size_t length)
143 ostream* stream =
reinterpret_cast< ostream*
>(png_get_io_ptr(png));
146 stream->write(reinterpret_cast< char* >(data), length);
149 wr->
set_error(
"ostream::write() failed");
152 catch (std::exception
const&
error)
158 assert(!
"caught something wrong");
159 wr->
set_error(
"write_data: caught something wrong");
167 static void flush_data(png_struct* png)
172 ostream* stream =
reinterpret_cast< ostream*
>(png_get_io_ptr(png));
178 wr->
set_error(
"ostream::flush() failed");
181 catch (std::exception
const&
error)
187 assert(!
"caught something wrong");
188 wr->
set_error(
"flush_data: caught something wrong");
199 #endif // PNGPP_WRITER_HPP_INCLUDED end_info m_end_info
Definition: io_base.hpp:461
png_info * get_png_info() const
Definition: info_base.hpp:59
void write_png() const
Definition: writer.hpp:89
writer(ostream &stream)
Constructs a writer prepared to write PNG image into a stream.
Definition: writer.hpp:74
Base class for PNG reader/writer classes.
Definition: io_base.hpp:62
void write() const
Definition: end_info.hpp:64
bool is_error() const
Definition: io_base.hpp:442
~writer()
Definition: writer.hpp:83
info m_info
Definition: io_base.hpp:460
std::string m_error
Definition: io_base.hpp:462
void raise_error()
Definition: io_base.hpp:447
png_struct * m_png
Definition: io_base.hpp:459
void write() const
Definition: info.hpp:116
png_info ** get_png_info_ptr()
Definition: info_base.hpp:64
png_byte byte
Definition: types.hpp:39
void write_end_info() const
Reads ending info about PNG image.
Definition: writer.hpp:128
void reset_error()
Definition: io_base.hpp:430
PNG writer class template. This is the low-level writing interface–use image class or generator clas...
Definition: writer.hpp:66
void destroy()
Definition: end_info.hpp:53
void write_info() const
Write info about PNG image.
Definition: writer.hpp:104
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
void write_row(byte *bytes)
Writes a row of image data at a time.
Definition: writer.hpp:116