CVR-Lib last update 20 Sep 2009

cvr::ioPNG Class Reference
[Image I/O Classes]

Class to read and write files with images and channels in PNG format. More...

#include <cvrIOPNG.h>

Inheritance diagram for cvr::ioPNG:

Inheritance graph
[legend]
Collaboration diagram for cvr::ioPNG:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 Parameter class of the ioBMP class. More...

Public Member Functions

 ioPNG ()
 ioPNG (const parameters &par)
 ioPNG (const ioPNG &other)
virtual ~ioPNG ()
const parametersgetParameters () const
virtual const std::string & name () const
virtual ioPNGclone () const
virtual ioPNGnewInstance () const
virtual bool load (const std::string &filename, image &theImage)
virtual bool load (const std::string &filename, matrix< ubyte > &theImage, palette &colors)
virtual bool load (const std::string &filename, matrix< ubyte > &chnl)
virtual bool load (const std::string &filename, matrix< float > &chnl)
virtual bool load (const std::string &filename, matrix< int32 > &chnl, palette &pal)
virtual bool load (const std::string &filename, matrix< int32 > &chnl)
virtual bool checkHeader (const std::string &filename, headerInformation &info)
bool save (const std::string &filename, const image &theImage)
bool save (const std::string &filename, const matrix< ubyte > &theChannel, const cvr::palette &colors)
bool save (const std::string &filename, const matrix< ubyte > &theChannel)
virtual bool save (const std::string &filename, const matrix< float > &chnl)
virtual bool save (const std::string &filename, const matrix< int32 > &chnl, const palette &pal)
virtual bool save (const std::string &filename, const matrix< int32 > &chnl)


Detailed Description

Class to read and write files with images and channels in PNG format.

It is NOT thread save, this means, the SAME instance can not be used from different threads or processes at the same time. If this occurs an unpredictible behaviour must be expected!. If this is required, just use a different instance of the functor for each thread, or use mutexes to avoid parallel accesses.

There are two implementations of this functor.

We recomend to use the libpng, it is more robust against not 100% correct PNG-files, and it is faster. Mianos' implementation is mainly for windows users that do not want to install the pnglib.

Reading PNG files

To read PNG files, you can use following code

Example:

 cvr::image anImg;                      // an image
 cvr::ioPNG loader;                     // the load functor
 loader.load("~/tmp/theFile.png",img); // load the image.

Saving PNG files

To save a Protable Network graphic (PNG) file just initialize the parameters and call the save member.

Example:

 cvr::image anImg;                      // an image
 ... [ initialize you image data here ]
 cvr::ioPNG saveImg;                    // the save functor
 saveImg.save("~/tmp/theFile.png",img); // save the image.

Exceptions:
BadPngStream is thrown when the Stream is corrupted.

Constructor & Destructor Documentation

cvr::ioPNG::ioPNG (  ) 

Default constructor.

cvr::ioPNG::ioPNG ( const parameters par  ) 

Constructor with parameters.

cvr::ioPNG::ioPNG ( const ioPNG other  ) 

Copy constructor.

virtual cvr::ioPNG::~ioPNG (  )  [virtual]

Destructor.


Member Function Documentation

virtual bool cvr::ioPNG::checkHeader ( const std::string &  filename,
headerInformation info 
) [virtual]

Check the data of the PNG header.

Parameters:
filename name of the PNG file to be tested
info header information.
Returns:
true if file is ok

Implements cvr::ioImageInterface.

virtual ioPNG* cvr::ioPNG::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::ioImageInterface.

const parameters& cvr::ioPNG::getParameters (  )  const

Returns current parameters.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
matrix< int32 > &  chnl 
) [virtual]

Load the contents as a integer mask.

Default implementation discards the palette of the other matrix<int32> method.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
matrix< int32 > &  chnl,
palette pal 
) [virtual]

Load the contents as a integer mask.

Default implementation returns the casting of the channel8 related method.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
matrix< float > &  chnl 
) [virtual]

Load a floating point channel.

Not many file formats support floating point channels, so the default implementation just casts a channel8 into the float.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
matrix< ubyte > &  chnl 
) [virtual]

Load the contents as a gray channel.

Default implementation just discards the palette of load(const std::string&,matrix<ubyte>&,palette&)

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
matrix< ubyte > &  theImage,
palette colors 
) [virtual]

Load indexed image.

Implements cvr::ioImageInterface.

virtual bool cvr::ioPNG::load ( const std::string &  filename,
image theImage 
) [virtual]

Load true-color image.

Implements cvr::ioImageInterface.

virtual const std::string& cvr::ioPNG::name (  )  const [virtual]

Returns the name of this class.

Reimplemented from cvr::ioImageInterface.

virtual ioPNG* cvr::ioPNG::newInstance (  )  const [virtual]

Returns a pointer to a new instance of this functor.

Implements cvr::ioImageInterface.

virtual bool cvr::ioPNG::save ( const std::string &  filename,
const matrix< int32 > &  chnl 
) [virtual]

Save the contents as a integer mask.

Default implementation discards the palette of the other matrix<int32> method.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::save ( const std::string &  filename,
const matrix< int32 > &  chnl,
const palette pal 
) [virtual]

Save the contents as a integer mask.

Default implementation returns the casting of the channel8 related method.

Reimplemented from cvr::ioImageInterface.

virtual bool cvr::ioPNG::save ( const std::string &  filename,
const matrix< float > &  chnl 
) [virtual]

Save a floating point channel.

Not many file formats support floating point channels, so the default implementation just casts the channel to a channel8, which is saved. You normally lose precision.

Reimplemented from cvr::ioImageInterface.

bool cvr::ioPNG::save ( const std::string &  filename,
const matrix< ubyte > &  theChannel 
) [virtual]

Save an gray scale channel.

Reimplemented from cvr::ioImageInterface.

bool cvr::ioPNG::save ( const std::string &  filename,
const matrix< ubyte > &  theChannel,
const cvr::palette colors 
) [virtual]

Save an "indexed" image contained in the given channel8 (indices) and the given color palette.

Implements cvr::ioImageInterface.

bool cvr::ioPNG::save ( const std::string &  filename,
const image theImage 
) [virtual]

This will save an image as a 24 bit RGB bitmap image.

Implements cvr::ioImageInterface.


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

Generated on Sun Sep 20 22:08:55 2009 for CVR-Lib by Doxygen 1.5.8