31 #ifndef PNGPP_IMAGE_HPP_INCLUDED 32 #define PNGPP_IMAGE_HPP_INCLUDED 51 template<
typename pixel >
95 image(
size_t width,
size_t height)
105 explicit image(std::string
const& filename)
114 template<
class transformation >
116 transformation
const& transform)
118 read(filename.c_str(), transform);
125 explicit image(
char const* filename)
134 template<
class transformation >
135 image(
char const* filename, transformation
const& transform)
137 read(filename, transform);
144 explicit image(std::istream& stream)
153 template<
class transformation >
154 image(std::istream& stream, transformation
const& transform)
163 void read(std::string
const& filename)
172 template<
class transformation >
173 void read(std::string
const& filename, transformation
const& transform)
175 read(filename.c_str(), transform);
182 void read(
char const* filename)
191 template<
class transformation >
192 void read(
char const* filename, transformation
const& transform)
194 std::ifstream stream(filename, std::ios::binary);
195 if (!stream.is_open())
199 stream.exceptions(std::ios::badbit);
207 void read(std::istream& stream)
216 template<
class transformation >
217 void read(std::istream& stream, transformation
const& transform)
226 template<
class istream >
236 template<
class istream,
class transformation >
237 void read_stream(istream& stream, transformation
const& transform)
240 pixcon.
read(stream, transform);
246 void write(std::string
const& filename)
248 write(filename.c_str());
256 std::ofstream stream(filename, std::ios::binary);
257 if (!stream.is_open())
261 stream.exceptions(std::ios::badbit);
276 template<
class ostream >
280 pixgen.
write(stream);
457 template<
typename base_impl >
475 return reinterpret_cast< byte*
> 489 image_info_ref_holder,
497 true > >(info, pixels)
517 image_info_ref_holder,
525 true > >(info, pixels)
536 #endif // PNGPP_IMAGE_HPP_INCLUDED The pixel row traits class template. Provides a common way to get starting address of the row for pac...
Definition: pixel_buffer.hpp:53
image_info m_info
Definition: image.hpp:530
void write(ostream &stream)
Writes an image to the stream.
Definition: generator.hpp:129
void set_pixel(size_t x, size_t y, pixel p)
Replaces a pixel at (x,y) position.
Definition: pixel_buffer.hpp:178
void set_tRNS(tRNS const &trns)
Definition: image.hpp:447
filter_type get_filter_type() const
Definition: image.hpp:403
image(std::string const &filename, transformation const &transform)
Constructs an image reading data from specified file using custom transformaton.
Definition: image.hpp:115
void read_stream(istream &stream, transformation const &transform)
Reads an image from a stream using custom transformation.
Definition: image.hpp:237
image(size_t width, size_t height)
Constructs an empty image of specified width and height.
Definition: image.hpp:95
row_type & get_row(size_t index)
Returns a reference to the row of image data at specified index.
Definition: image.hpp:335
interlace_type
Definition: types.hpp:79
std::vector< byte > tRNS
The palette transparency map type. Currently implemented as std::vector of png::byte.
Definition: tRNS.hpp:44
void set_palette(palette const &plte)
Replaces the image palette.
Definition: image.hpp:432
void read(std::istream &stream, transformation const &transform)
Reads an image from a stream using custom transformation.
Definition: image.hpp:217
Base class for PNG reader/writer classes.
Definition: io_base.hpp:62
byte * get_next_row(size_t pos)
Returns the starting address of a pos-th row in the image's pixel buffer.
Definition: image.hpp:472
compression_type get_compression_type() const
Definition: image_info.hpp:116
void write(char const *filename)
Writes an image to specified file.
Definition: image.hpp:254
void set_palette(palette const &plte)
Definition: image_info.hpp:146
Definition: pixel_buffer.hpp:211
size_t get_height() const
Definition: pixel_buffer.hpp:94
size_t get_width() const
Definition: pixel_buffer.hpp:89
pixel_buffer< pixel > pixbuf
The pixel buffer type for pixel.
Definition: image.hpp:63
interlace_type get_interlace_type() const
Definition: image_info.hpp:106
void set_filter_type(filter_type filter)
Definition: image_info.hpp:131
interlace_type get_interlace_type() const
Definition: image.hpp:383
filter_type
Definition: types.hpp:91
void set_interlace_type(interlace_type interlace)
Definition: image_info.hpp:111
std::vector< color > palette
The palette type. Currently implemented as std::vector of png::color.
Definition: palette.hpp:44
Pixel traits class template.
Definition: pixel_traits.hpp:48
image(std::string const &filename)
Constructs an image reading data from specified file using default converting transform.
Definition: image.hpp:105
Holds information about PNG image.
Definition: image_info.hpp:47
pixbuf & m_pixbuf
Definition: image.hpp:480
row_type & get_row(size_t index)
Returns a reference to the row of image data at specified index.
Definition: pixel_buffer.hpp:126
pixbuf const & get_pixbuf() const
Returns a const reference to image pixel buffer.
Definition: image.hpp:294
palette & get_palette()
Returns a reference to the image palette.
Definition: image.hpp:416
palette const & get_palette() const
Definition: image_info.hpp:136
row_type const & get_row(size_t index) const
Returns a const reference to the row of image data at specified index.
Definition: image.hpp:346
void set_width(size_t width)
Definition: image_info.hpp:71
void set_pixel(size_t x, size_t y, pixel p)
Replaces a pixel at (x,y) position.
Definition: image.hpp:378
void set_interlace_type(interlace_type interlace)
Definition: image.hpp:388
image(char const *filename)
Constructs an image reading data from specified file using default converting transform.
Definition: image.hpp:125
compression_type
Definition: types.hpp:85
An image_info holder class. Stores a reference to the image_info object. The image_info object itself...
Definition: streaming_base.hpp:67
pixbuf m_pixbuf
Definition: image.hpp:531
void write(std::string const &filename)
Writes an image to specified file.
Definition: image.hpp:246
size_t get_height() const
Definition: image.hpp:314
palette const & get_palette() const
Returns a const reference to the image palette.
Definition: image.hpp:424
tRNS & get_tRNS()
Definition: image.hpp:442
pixel_generator(image_info &info, pixbuf &pixels)
Definition: image.hpp:521
void read_stream(istream &stream)
Reads an image from a stream using default converting transform.
Definition: image.hpp:227
Class template to represent PNG image.
Definition: image.hpp:52
A common base class template for pixel_consumer and pixel_generator classes.
Definition: image.hpp:458
png_byte byte
Definition: types.hpp:39
void reset(size_t pass)
Definition: image.hpp:501
filter_type get_filter_type() const
Definition: image_info.hpp:126
Pixel consumer class template.
Definition: consumer.hpp:125
tRNS const & get_tRNS() const
Definition: image.hpp:437
size_t get_width() const
Definition: image.hpp:309
void set_compression_type(compression_type compression)
Definition: image.hpp:398
void set_compression_type(compression_type compression)
Definition: image_info.hpp:121
std::vector< pixel > row_type
A row of pixel data.
Definition: pixel_buffer.hpp:67
pixel_traits< pixel > traits
The pixel traits type for pixel.
Definition: image.hpp:58
pixbuf & get_pixbuf()
Returns a reference to image pixel buffer.
Definition: image.hpp:286
pixbuf::row_type row_type
Represents a row of image pixel data.
Definition: image.hpp:68
void read(std::string const &filename, transformation const &transform)
Reads an image from specified file using custom transformaton.
Definition: image.hpp:173
pixel get_pixel(size_t x, size_t y) const
Returns a pixel at (x,y) position.
Definition: pixel_buffer.hpp:170
pixel_consumer(image_info &info, pixbuf &pixels)
Definition: image.hpp:493
void read(char const *filename)
Reads an image from specified file using default converting transform.
Definition: image.hpp:182
void set_height(size_t height)
Definition: image_info.hpp:81
row_type const & operator[](size_t index) const
The non-checking version of get_row() method.
Definition: image.hpp:362
void resize(size_t width, size_t height)
Resizes the pixel buffer.
Definition: pixel_buffer.hpp:105
void resize(size_t width, size_t height)
Resizes the image pixel buffer.
Definition: image.hpp:322
streaming_impl(image_info &info, pixbuf &pixels)
Definition: image.hpp:462
Holds information about PNG image. Adapter class for IO image operations.
Definition: info.hpp:45
image(std::istream &stream)
Constructs an image reading data from a stream using default converting transform.
Definition: image.hpp:144
void set_tRNS(tRNS const &trns)
Definition: image_info.hpp:169
void set_pixbuf(pixbuf const &buffer)
Replaces the image pixel buffer.
Definition: image.hpp:304
tRNS const & get_tRNS() const
Definition: image_info.hpp:159
image_info make_image_info()
Returns an image_info object with color_type and bit_depth fields setup appropriate for the pixel typ...
Definition: image_info.hpp:192
image(char const *filename, transformation const &transform)
Constructs an image reading data from specified file using custom transformaton.
Definition: image.hpp:135
Exception class to represent standard library errors (generally IO).
Definition: error.hpp:65
convert_color_space< pixel > transform_convert
A transformation functor to convert any image to appropriate color space.
Definition: image.hpp:74
image(std::istream &stream, transformation const &transform)
Constructs an image reading data from a stream using custom transformation.
Definition: image.hpp:154
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:252
void write_stream(std::ostream &stream)
Writes an image to a stream.
Definition: image.hpp:268
void read(char const *filename, transformation const &transform)
Reads an image from specified file using custom transformaton.
Definition: image.hpp:192
void read(std::istream &stream)
Reads an image from a stream using default converting transform.
Definition: image.hpp:207
The row_traits specialization for unpacked pixel rows.
Definition: pixel_buffer.hpp:194
image()
Constructs an empty image.
Definition: image.hpp:87
void read(std::string const &filename)
Reads an image from specified file using default converting transform.
Definition: image.hpp:163
void read(istream &stream)
Reads an image from the stream using default io transformation.
Definition: consumer.hpp:144
row_type & operator[](size_t index)
The non-checking version of get_row() method.
Definition: image.hpp:354
void set_filter_type(filter_type filter)
Definition: image.hpp:408
compression_type get_compression_type() const
Definition: image.hpp:393
Pixel generator class template.
Definition: generator.hpp:116
The pixel buffer adapter for reading pixel data.
Definition: image.hpp:486
void write_stream(ostream &stream)
Writes an image to a stream.
Definition: image.hpp:277
pixel get_pixel(size_t x, size_t y) const
Returns a pixel at (x,y) position.
Definition: image.hpp:370
The pixel buffer adapter for writing pixel data.
Definition: image.hpp:514