png++
0.2.9
|
Pixel generator class template. More...
#include <generator.hpp>
Public Member Functions | |
template<typename ostream > | |
void | write (ostream &stream) |
Writes an image to the stream. 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 | |
generator (image_info &info) | |
Constructs a generator object using passed image_info object to store image information. More... | |
generator (size_t width, size_t height) | |
Constructs a generator object prepared to generate an image of specified width and height. More... | |
Protected Member Functions inherited from png::streaming_base< pixel, info_holder > | |
void | reset (size_t) |
image_info & | get_info () |
Additional Inherited Members | |
Public Types inherited from png::streaming_base< pixel, info_holder > | |
typedef pixel_traits< pixel > | traits |
Protected Attributes inherited from png::streaming_base< pixel, info_holder > | |
info_holder | m_info_holder |
Pixel generator class template.
Used as a base class for custom pixel generator classes as well as inside image class implementation to write pixels from the pixel buffer.
A usage example can be found in example/pixel_generator.cpp
.
Encapsulates PNG image writing procedure. In order to create a custom pixel generator use CRTP trick:
Your pixel generator 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 needed by the writer. The position of the row being written 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 storing an appropriate amount of pixels (i.e. the width of the image being written). 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. You do not have to implement this method unless you are going to support interlaced image generation.
An optional template parameter info_holder
encapsulated image_info storage policy. Please refer to consumer class documentation for the detailed description of this parameter.
An optional bool
template parameter interlacing_supported
specifies whether writing interlacing images is supported by your generator class. It defaults to false
. An attempt to write an interlaced image will result in throwing std::logic_error
.
In order to fully support interlacing specify true
for interlacing_supported
parameter and implement reset()
method. You must generate the same pixels for every pass to get the correct PNG image output.
|
protected |
|
inlineexplicitprotected |
Constructs a generator object using passed image_info object to store image information.
|
inlineprotected |
Constructs a generator object prepared to generate an image of specified width and height.
|
inline |
Writes an image to the stream.
Essentially, this method constructs a writer object and instructs it to write the image to the stream. It handles writing interlaced images as long as your generator class supports this.
Referenced by png::image< pixel, pixel_buffer_type >::write_stream().