31 #ifndef PNGPP_IMAGE_HPP_INCLUDED 32 #define PNGPP_IMAGE_HPP_INCLUDED 61 template<
typename pixel,
typename pixel_buffer_type = pixel_buffer< pixel > >
117 explicit image(std::string
const& filename)
126 template<
class transformation >
128 transformation
const& transform)
130 read(filename.c_str(), transform);
137 explicit image(
char const* filename)
146 template<
class transformation >
147 image(
char const* filename, transformation
const& transform)
149 read(filename, transform);
156 explicit image(std::istream& stream)
165 template<
class transformation >
166 image(std::istream& stream, transformation
const& transform)
175 void read(std::string
const& filename)
184 template<
class transformation >
185 void read(std::string
const& filename, transformation
const& transform)
187 read(filename.c_str(), transform);
194 void read(
char const* filename)
203 template<
class transformation >
204 void read(
char const* filename, transformation
const& transform)
206 std::ifstream stream(filename, std::ios::binary);
207 if (!stream.is_open())
211 stream.exceptions(std::ios::badbit);
219 void read(std::istream& stream)
228 template<
class transformation >
229 void read(std::istream& stream, transformation
const& transform)
238 template<
class istream >
248 template<
class istream,
class transformation >
249 void read_stream(istream& stream, transformation
const& transform)
252 pixcon.
read(stream, transform);
258 void write(std::string
const& filename)
260 write(filename.c_str());
268 std::ofstream stream(filename, std::ios::binary);
269 if (!stream.is_open())
273 stream.exceptions(std::ios::badbit);
280 template<
class ostream >
284 pixgen.
write(stream);
471 template<
typename base_impl >
488 typedef typename pixbuf::row_traits
row_traits;
489 return reinterpret_cast< byte*
> 490 (row_traits::get_data(
m_pixbuf.get_row(pos)));
503 image_info_ref_holder,
511 true > >(info, pixels)
531 image_info_ref_holder,
539 true > >(info, pixels)
550 #endif // PNGPP_IMAGE_HPP_INCLUDED filter_type get_filter_type() const
Definition: image_info.hpp:127
void read_stream(istream &stream, transformation const &transform)
Reads an image from a stream using custom transformation.
Definition: image.hpp:249
convert_color_space< pixel > transform_convert
A transformation functor to convert any image to appropriate color space.
Definition: image.hpp:86
The pixel row traits class template. Provides a common way to get starting address of the row for pac...
Definition: pixel_buffer.hpp:53
void write(ostream &stream)
Writes an image to the stream.
Definition: generator.hpp:129
pixbuf::row_type row_type
Represents a row of image pixel data.
Definition: image.hpp:78
image(uint_32 width, uint_32 height)
Constructs an empty image of specified width and height.
Definition: image.hpp:107
pixel_generator(image_info &info, pixbuf &pixels)
Definition: image.hpp:535
pixbuf::row_const_access row_const_access
Definition: image.hpp:80
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:486
pixbuf & m_pixbuf
Definition: image.hpp:494
interlace_type
Definition: types.hpp:79
image()
Constructs an empty image.
Definition: image.hpp:99
std::vector< byte > tRNS
The palette transparency map type. Currently implemented as std::vector of png::byte.
Definition: tRNS.hpp:44
pixbuf::row_access row_access
Definition: image.hpp:79
Base class for PNG reader/writer classes.
Definition: io_base.hpp:62
void set_palette(palette const &plte)
Definition: image_info.hpp:147
double get_gamma() const
Definition: image_info.hpp:175
void read(char const *filename)
Reads an image from specified file using default converting transform.
Definition: image.hpp:194
void set_tRNS(tRNS const &trns)
Definition: image.hpp:451
void set_filter_type(filter_type filter)
Definition: image_info.hpp:132
image(std::istream &stream, transformation const &transform)
Constructs an image reading data from a stream using custom transformation.
Definition: image.hpp:166
filter_type
Definition: types.hpp:91
void set_interlace_type(interlace_type interlace)
Definition: image_info.hpp:112
filter_type get_filter_type() const
Definition: image.hpp:407
void set_palette(palette const &plte)
Replaces the image palette.
Definition: image.hpp:436
tRNS const & get_tRNS() const
Definition: image_info.hpp:160
std::vector< color > palette
The palette type. Currently implemented as std::vector of png::color.
Definition: palette.hpp:44
void write(std::string const &filename)
Writes an image to specified file.
Definition: image.hpp:258
pixbuf const & get_pixbuf() const
Returns a const reference to image pixel buffer.
Definition: image.hpp:298
Pixel traits class template.
Definition: pixel_traits.hpp:48
void read(char const *filename, transformation const &transform)
Reads an image from specified file using custom transformaton.
Definition: image.hpp:204
void read(std::istream &stream)
Reads an image from a stream using default converting transform.
Definition: image.hpp:219
void read(std::string const &filename, transformation const &transform)
Reads an image from specified file using custom transformaton.
Definition: image.hpp:185
Holds information about PNG image.
Definition: image_info.hpp:47
void reset(size_t pass)
Definition: image.hpp:515
void write(char const *filename)
Writes an image to specified file.
Definition: image.hpp:266
void resize(uint_32 width, uint_32 height)
Resizes the image pixel buffer.
Definition: image.hpp:326
row_const_access operator[](size_t index) const
The non-checking version of get_row() method.
Definition: image.hpp:366
pixel get_pixel(size_t x, size_t y) const
Returns a pixel at (x,y) position.
Definition: image.hpp:374
void set_gamma(double gamma)
Definition: image.hpp:461
image(std::istream &stream)
Constructs an image reading data from a stream using default converting transform.
Definition: image.hpp:156
image(std::string const &filename, transformation const &transform)
Constructs an image reading data from specified file using custom transformaton.
Definition: image.hpp:127
compression_type
Definition: types.hpp:85
void set_width(uint_32 width)
Definition: image_info.hpp:72
An image_info holder class. Stores a reference to the image_info object. The image_info object itself...
Definition: streaming_base.hpp:67
png_uint_32 uint_32
Definition: types.hpp:41
Class template to represent PNG image.
Definition: image.hpp:62
interlace_type get_interlace_type() const
Definition: image_info.hpp:107
A common base class template for pixel_consumer and pixel_generator classes.
Definition: image.hpp:472
compression_type get_compression_type() const
Definition: image.hpp:397
png_byte byte
Definition: types.hpp:39
image(std::string const &filename)
Constructs an image reading data from specified file using default converting transform.
Definition: image.hpp:117
double get_gamma() const
Definition: image.hpp:456
Pixel consumer class template.
Definition: consumer.hpp:125
compression_type get_compression_type() const
Definition: image_info.hpp:117
pixbuf m_pixbuf
Definition: image.hpp:545
tRNS const & get_tRNS() const
Definition: image.hpp:441
palette const & get_palette() const
Returns a const reference to the image palette.
Definition: image.hpp:428
palette const & get_palette() const
Definition: image_info.hpp:137
image(char const *filename, transformation const &transform)
Constructs an image reading data from specified file using custom transformaton.
Definition: image.hpp:147
void set_compression_type(compression_type compression)
Definition: image_info.hpp:122
void set_pixbuf(pixbuf const &buffer)
Replaces the image pixel buffer.
Definition: image.hpp:308
row_const_access get_row(size_t index) const
Returns a const reference to the row of image data at specified index.
Definition: image.hpp:350
image(char const *filename)
Constructs an image reading data from specified file using default converting transform.
Definition: image.hpp:137
uint_32 get_height() const
Definition: image.hpp:318
void set_compression_type(compression_type compression)
Definition: image.hpp:402
interlace_type get_interlace_type() const
Definition: image.hpp:387
void set_height(uint_32 height)
Definition: image_info.hpp:82
pixel_traits< pixel > traits
The pixel traits type for pixel.
Definition: image.hpp:68
row_access get_row(size_t index)
Returns a reference to the row of image data at specified index.
Definition: image.hpp:339
tRNS & get_tRNS()
Definition: image.hpp:446
row_access operator[](size_t index)
The non-checking version of get_row() method.
Definition: image.hpp:358
palette & get_palette()
Returns a reference to the image palette.
Definition: image.hpp:420
Holds information about PNG image. Adapter class for IO image operations.
Definition: info.hpp:45
void set_tRNS(tRNS const &trns)
Definition: image_info.hpp:170
pixbuf & get_pixbuf()
Returns a reference to image pixel buffer.
Definition: image.hpp:290
void set_filter_type(filter_type filter)
Definition: image.hpp:412
void write_stream(ostream &stream)
Writes an image to a stream.
Definition: image.hpp:281
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:204
streaming_impl(image_info &info, pixbuf &pixels)
Definition: image.hpp:476
Exception class to represent standard library errors (generally IO).
Definition: error.hpp:76
IO transformation class template. Converts image color space.
Definition: convert_color_space.hpp:256
pixel_buffer_type pixbuf
The pixel buffer type for pixel.
Definition: image.hpp:73
void read_stream(istream &stream)
Reads an image from a stream using default converting transform.
Definition: image.hpp:239
void read(istream &stream)
Reads an image from the stream using default io transformation.
Definition: consumer.hpp:144
void set_pixel(size_t x, size_t y, pixel p)
Replaces a pixel at (x,y) position.
Definition: image.hpp:382
uint_32 get_width() const
Definition: image.hpp:313
void set_interlace_type(interlace_type interlace)
Definition: image.hpp:392
void set_gamma(double gamma)
Definition: image_info.hpp:180
pixel_consumer(image_info &info, pixbuf &pixels)
Definition: image.hpp:507
void read(std::string const &filename)
Reads an image from specified file using default converting transform.
Definition: image.hpp:175
image_info m_info
Definition: image.hpp:544
Pixel generator class template.
Definition: generator.hpp:116
The pixel buffer adapter for reading pixel data.
Definition: image.hpp:500
void read(std::istream &stream, transformation const &transform)
Reads an image from a stream using custom transformation.
Definition: image.hpp:229
The pixel buffer adapter for writing pixel data.
Definition: image.hpp:528