png++  0.2.7
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
png::image< pixel, pixel_buffer_type > Class Template Reference

Class template to represent PNG image. More...

#include <image.hpp>

Classes

class  pixel_consumer
 The pixel buffer adapter for reading pixel data. More...
 
class  pixel_generator
 The pixel buffer adapter for writing pixel data. More...
 
class  streaming_impl
 A common base class template for pixel_consumer and pixel_generator classes. More...
 
struct  transform_identity
 The default io transformation: does nothing. More...
 

Public Types

typedef pixel_traits< pixel > traits
 The pixel traits type for pixel. More...
 
typedef pixel_buffer_type pixbuf
 The pixel buffer type for pixel. More...
 
typedef pixbuf::row_type row_type
 Represents a row of image pixel data. More...
 
typedef pixbuf::row_access row_access
 
typedef pixbuf::row_const_access row_const_access
 
typedef convert_color_space
< pixel > 
transform_convert
 A transformation functor to convert any image to appropriate color space. More...
 

Public Member Functions

 image ()
 Constructs an empty image. More...
 
 image (size_t width, size_t height)
 Constructs an empty image of specified width and height. More...
 
 image (std::string const &filename)
 Constructs an image reading data from specified file using default converting transform. More...
 
template<class transformation >
 image (std::string const &filename, transformation const &transform)
 Constructs an image reading data from specified file using custom transformaton. More...
 
 image (char const *filename)
 Constructs an image reading data from specified file using default converting transform. More...
 
template<class transformation >
 image (char const *filename, transformation const &transform)
 Constructs an image reading data from specified file using custom transformaton. More...
 
 image (std::istream &stream)
 Constructs an image reading data from a stream using default converting transform. More...
 
template<class transformation >
 image (std::istream &stream, transformation const &transform)
 Constructs an image reading data from a stream using custom transformation. More...
 
void read (std::string const &filename)
 Reads an image from specified file using default converting transform. More...
 
template<class transformation >
void read (std::string const &filename, transformation const &transform)
 Reads an image from specified file using custom transformaton. More...
 
void read (char const *filename)
 Reads an image from specified file using default converting transform. More...
 
template<class transformation >
void read (char const *filename, transformation const &transform)
 Reads an image from specified file using custom transformaton. More...
 
void read (std::istream &stream)
 Reads an image from a stream using default converting transform. More...
 
template<class transformation >
void read (std::istream &stream, transformation const &transform)
 Reads an image from a stream using custom transformation. More...
 
template<class istream >
void read_stream (istream &stream)
 Reads an image from a stream using default converting transform. More...
 
template<class istream , class transformation >
void read_stream (istream &stream, transformation const &transform)
 Reads an image from a stream using custom transformation. More...
 
void write (std::string const &filename)
 Writes an image to specified file. More...
 
void write (char const *filename)
 Writes an image to specified file. More...
 
template<class ostream >
void write_stream (ostream &stream)
 Writes an image to a stream. More...
 
pixbufget_pixbuf ()
 Returns a reference to image pixel buffer. More...
 
pixbuf const & get_pixbuf () const
 Returns a const reference to image pixel buffer. More...
 
void set_pixbuf (pixbuf const &buffer)
 Replaces the image pixel buffer. More...
 
size_t get_width () const
 
size_t get_height () const
 
void resize (size_t width, size_t height)
 Resizes the image pixel buffer. More...
 
row_access get_row (size_t index)
 Returns a reference to the row of image data at specified index. More...
 
row_const_access get_row (size_t index) const
 Returns a const reference to the row of image data at specified index. More...
 
row_access operator[] (size_t index)
 The non-checking version of get_row() method. More...
 
row_const_access operator[] (size_t index) const
 The non-checking version of get_row() method. More...
 
pixel get_pixel (size_t x, size_t y) const
 Returns a pixel at (x,y) position. More...
 
void set_pixel (size_t x, size_t y, pixel p)
 Replaces a pixel at (x,y) position. More...
 
interlace_type get_interlace_type () const
 
void set_interlace_type (interlace_type interlace)
 
compression_type get_compression_type () const
 
void set_compression_type (compression_type compression)
 
filter_type get_filter_type () const
 
void set_filter_type (filter_type filter)
 
paletteget_palette ()
 Returns a reference to the image palette. More...
 
palette const & get_palette () const
 Returns a const reference to the image palette. More...
 
void set_palette (palette const &plte)
 Replaces the image palette. More...
 
tRNS const & get_tRNS () const
 
tRNSget_tRNS ()
 
void set_tRNS (tRNS const &trns)
 

Protected Attributes

image_info m_info
 
pixbuf m_pixbuf
 

Detailed Description

template<typename pixel, typename pixel_buffer_type = pixel_buffer< pixel >>
class png::image< pixel, pixel_buffer_type >

Class template to represent PNG image.

The image consists of pixel data as well as additional image info like interlace type, compression method, palette (for colormap-based images) etc. Provides methods to read and write images from/to a generic stream and to manipulate image pixels.

The default pixel_buffer stores pixels in a vector of vectors, which is good for openning, editing or converting an image to any pixel type. But for simple and fast image unpacking to one memory chunk this approch is unacceptable, because it leads to multiple memory allocations, the unpacked image is spread across the memory and client code needs to gather it manualy. solid_pixel_buffer solves this problem, but with restriction: pixels with fractional number of bytes per channel are not allowed (see solid_pixel_buffer.hpp for details).

Member Typedef Documentation

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef pixel_traits< pixel > png::image< pixel, pixel_buffer_type >::traits

The pixel traits type for pixel.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef pixel_buffer_type png::image< pixel, pixel_buffer_type >::pixbuf

The pixel buffer type for pixel.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef pixbuf::row_type png::image< pixel, pixel_buffer_type >::row_type

Represents a row of image pixel data.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef pixbuf::row_access png::image< pixel, pixel_buffer_type >::row_access
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef pixbuf::row_const_access png::image< pixel, pixel_buffer_type >::row_const_access
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
typedef convert_color_space< pixel > png::image< pixel, pixel_buffer_type >::transform_convert

A transformation functor to convert any image to appropriate color space.

Constructor & Destructor Documentation

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
png::image< pixel, pixel_buffer_type >::image ( )
inline

Constructs an empty image.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
png::image< pixel, pixel_buffer_type >::image ( size_t  width,
size_t  height 
)
inline

Constructs an empty image of specified width and height.

References png::image< pixel, pixel_buffer_type >::resize().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
png::image< pixel, pixel_buffer_type >::image ( std::string const &  filename)
inlineexplicit

Constructs an image reading data from specified file using default converting transform.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
png::image< pixel, pixel_buffer_type >::image ( std::string const &  filename,
transformation const &  transform 
)
inline

Constructs an image reading data from specified file using custom transformaton.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
png::image< pixel, pixel_buffer_type >::image ( char const *  filename)
inlineexplicit

Constructs an image reading data from specified file using default converting transform.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
png::image< pixel, pixel_buffer_type >::image ( char const *  filename,
transformation const &  transform 
)
inline

Constructs an image reading data from specified file using custom transformaton.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
png::image< pixel, pixel_buffer_type >::image ( std::istream &  stream)
inlineexplicit

Constructs an image reading data from a stream using default converting transform.

References png::image< pixel, pixel_buffer_type >::read_stream().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
png::image< pixel, pixel_buffer_type >::image ( std::istream &  stream,
transformation const &  transform 
)
inline

Constructs an image reading data from a stream using custom transformation.

References png::image< pixel, pixel_buffer_type >::read_stream().

Member Function Documentation

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::read ( std::string const &  filename)
inline

Reads an image from specified file using default converting transform.

Referenced by png::image< pixel, pixel_buffer_type >::image(), and png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
void png::image< pixel, pixel_buffer_type >::read ( std::string const &  filename,
transformation const &  transform 
)
inline

Reads an image from specified file using custom transformaton.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::read ( char const *  filename)
inline

Reads an image from specified file using default converting transform.

References png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
void png::image< pixel, pixel_buffer_type >::read ( char const *  filename,
transformation const &  transform 
)
inline

Reads an image from specified file using custom transformaton.

References png::image< pixel, pixel_buffer_type >::read_stream().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::read ( std::istream &  stream)
inline

Reads an image from a stream using default converting transform.

References png::image< pixel, pixel_buffer_type >::read_stream().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class transformation >
void png::image< pixel, pixel_buffer_type >::read ( std::istream &  stream,
transformation const &  transform 
)
inline

Reads an image from a stream using custom transformation.

References png::image< pixel, pixel_buffer_type >::read_stream().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class istream >
void png::image< pixel, pixel_buffer_type >::read_stream ( istream &  stream)
inline

Reads an image from a stream using default converting transform.

Referenced by png::image< pixel, pixel_buffer_type >::image(), and png::image< pixel, pixel_buffer_type >::read().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class istream , class transformation >
void png::image< pixel, pixel_buffer_type >::read_stream ( istream &  stream,
transformation const &  transform 
)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::write ( std::string const &  filename)
inline

Writes an image to specified file.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::write ( char const *  filename)
inline

Writes an image to specified file.

References png::image< pixel, pixel_buffer_type >::write_stream().

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
template<class ostream >
void png::image< pixel, pixel_buffer_type >::write_stream ( ostream &  stream)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
pixbuf& png::image< pixel, pixel_buffer_type >::get_pixbuf ( )
inline

Returns a reference to image pixel buffer.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
pixbuf const& png::image< pixel, pixel_buffer_type >::get_pixbuf ( ) const
inline

Returns a const reference to image pixel buffer.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_pixbuf ( pixbuf const &  buffer)
inline

Replaces the image pixel buffer.

Parameters
buffera pixel buffer object to take a copy from

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
size_t png::image< pixel, pixel_buffer_type >::get_width ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
size_t png::image< pixel, pixel_buffer_type >::get_height ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::resize ( size_t  width,
size_t  height 
)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
row_access png::image< pixel, pixel_buffer_type >::get_row ( size_t  index)
inline

Returns a reference to the row of image data at specified index.

See also
pixel_buffer::get_row()

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
row_const_access png::image< pixel, pixel_buffer_type >::get_row ( size_t  index) const
inline

Returns a const reference to the row of image data at specified index.

See also
pixel_buffer::get_row()

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
row_access png::image< pixel, pixel_buffer_type >::operator[] ( size_t  index)
inline

The non-checking version of get_row() method.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
row_const_access png::image< pixel, pixel_buffer_type >::operator[] ( size_t  index) const
inline

The non-checking version of get_row() method.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
pixel png::image< pixel, pixel_buffer_type >::get_pixel ( size_t  x,
size_t  y 
) const
inline

Returns a pixel at (x,y) position.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_pixel ( size_t  x,
size_t  y,
pixel  p 
)
inline

Replaces a pixel at (x,y) position.

References png::image< pixel, pixel_buffer_type >::m_pixbuf.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
interlace_type png::image< pixel, pixel_buffer_type >::get_interlace_type ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_interlace_type ( interlace_type  interlace)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
compression_type png::image< pixel, pixel_buffer_type >::get_compression_type ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_compression_type ( compression_type  compression)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
filter_type png::image< pixel, pixel_buffer_type >::get_filter_type ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_filter_type ( filter_type  filter)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
palette& png::image< pixel, pixel_buffer_type >::get_palette ( )
inline

Returns a reference to the image palette.

References png::image_info::get_palette(), and png::image< pixel, pixel_buffer_type >::m_info.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
palette const& png::image< pixel, pixel_buffer_type >::get_palette ( ) const
inline

Returns a const reference to the image palette.

References png::image_info::get_palette(), and png::image< pixel, pixel_buffer_type >::m_info.

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_palette ( palette const &  plte)
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
tRNS const& png::image< pixel, pixel_buffer_type >::get_tRNS ( ) const
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
tRNS& png::image< pixel, pixel_buffer_type >::get_tRNS ( )
inline
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
void png::image< pixel, pixel_buffer_type >::set_tRNS ( tRNS const &  trns)
inline

Member Data Documentation

template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
image_info png::image< pixel, pixel_buffer_type >::m_info
protected
template<typename pixel , typename pixel_buffer_type = pixel_buffer< pixel >>
pixbuf png::image< pixel, pixel_buffer_type >::m_pixbuf
protected

The documentation for this class was generated from the following file: