png++
0.2.9
|
Pixel consumer class template. More...
#include <consumer.hpp>
Classes | |
struct | transform_identity |
The default io transformation: does nothing. More... | |
Public Types | |
typedef pixel_traits< pixel > | traits |
Public Types inherited from png::streaming_base< pixel, info_holder > | |
typedef pixel_traits< pixel > | traits |
Public Member Functions | |
template<typename istream > | |
void | read (istream &stream) |
Reads an image from the stream using default io transformation. More... | |
template<typename istream , class transformation > | |
void | read (istream &stream, transformation const &transform) |
Reads an image from the stream using custom io transformation. More... | |
Public Member Functions inherited from png::streaming_base< pixel, info_holder > | |
streaming_base (image_info &info) | |
streaming_base (uint_32 width, uint_32 height) | |
image_info const & | get_info () const |
Protected Types | |
typedef streaming_base< pixel, info_holder > | base |
Protected Member Functions | |
consumer (image_info &info) | |
Constructs a consumer object using passed image_info object to store image information. More... | |
Protected Member Functions inherited from png::streaming_base< pixel, info_holder > | |
void | reset (size_t) |
image_info & | get_info () |
Additional Inherited Members | |
Protected Attributes inherited from png::streaming_base< pixel, info_holder > | |
info_holder | m_info_holder |
Pixel consumer class template.
Used as a base class for custom pixel consumer classes as well as inside image class implementation to read pixels into the pixel buffer.
Encapsulates PNG image reading procedure. In order to create a custom pixel consumer use CRTP trick:
Your pixel consumer class should implement get_next_row()
method and reset()
method (optional). Their signatures are as follows:
The get_next_row()
method is called every time a new row of image data is available to the reader. The position of the row being read is passed as pos
parameter. The pos
takes values from 0
to <image_height>-1 inclusively. The method should return the starting address of a row buffer capable of storing appropriate amount of pixels (i.e. the width of the image being read). The address should be casted to png::byte* pointer type using
reinterpret_cast<>
or a C-style cast.
The optional reset()
method is called every time the new pass of interlaced image processing starts. The number of interlace pass is avaiable as the only parameter of the method. For non-interlaced images the method is called once prior to any calls to get_next_row()
. The value of 0
is passed for the pass
number.
An optional template parameter info_holder
encapsulates image_info storage policy. Using def_image_info_holder results in image_info object stored as a sub-object of the consumer class. You may specify image_info_ref_holder in order to use a reference to the externally stored image_info object. This way you will have to construct the consumer object passing the reference to image_info object.
Also, you might want implement an info holder object yourself to fine-tune your code. In any case, you can access the image_info object from your consumer class methods using the following code:
An optional bool
template parameter interlacing_supported
specifies whether reading interlacing images is supported by your consumer class. It defaults to false
. An attempt to read an interlaced image will result in discarding pixels obtained at all the interlacing passes except the last one.
In order to fully support interlacing specify true
for interlacing_supported
parameter and implement reset()
method.
typedef pixel_traits< pixel > png::consumer< pixel, pixcon, info_holder, interlacing_supported >::traits |
|
protected |
|
inlineexplicitprotected |
Constructs a consumer object using passed image_info object to store image information.
|
inline |
Reads an image from the stream using default io transformation.
Referenced by png::consumer< pixel, pixel_consumer, image_info_ref_holder, true >::read(), and png::image< pixel, pixel_buffer_type >::read_stream().
|
inline |
Reads an image from the stream using custom io transformation.
Essentially, this method constructs a reader object and instructs it to read the image from the stream. It handles IO transformation, as well as interlaced image reading.