latest version v1.9 - last update 10 Apr 2010 |
Functor to read a Portable Network Graphic (PNG) file. More...
#include <ltiPNGFunctor.h>
Public Member Functions | |
loadPNG () | |
~loadPNG () | |
virtual const char * | getTypeName () const |
bool | apply (image &theImage) |
bool | apply (channel8 &theChannel, lti::palette &colors) |
bool | load (const std::string &filename, image &theImage) |
bool | load (std::ifstream &file, image &theImage) |
bool | load (const std::string &filename, channel8 &theImage, lti::palette &colors) |
virtual functor * | clone () const |
bool | checkHeader (const std::string &filename, point &imageSize, int &bitsPerPixel, int &imageType) |
Functor to read a Portable Network Graphic (PNG) file.
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!
Example:
lti::image anImg; // an image ... lti::loadPNG myImg; // the load functor lti::loadPNG::parameters param; // functor parameters param.filename = "~/tmp/theFile.png"; // name of the PNG file myImg.setParameters(param); // set the functor parameters myImg.apply(anImg); // load the file
You can also use the more confortable shortcut:
lti::image anImg; // an image ... lti::loadPNG loadImg; // the load functor loadImg.load("~/tmp/theFile.png",img); // load the image.
BadPngStream | is thrown when the Stream is corrupted. |
For more information on implementation issues see ioPNG
lti::loadPNG::loadPNG | ( | ) |
default constructor
lti::loadPNG::~loadPNG | ( | ) |
destructor
bool lti::loadPNG::apply | ( | channel8 & | theChannel, | |
lti::palette & | colors | |||
) | [virtual] |
load Image.
BadPngStream | is thrown when the Stream is corrupted. |
Reimplemented from lti::ioFunctor.
bool lti::loadPNG::apply | ( | image & | theImage | ) | [virtual] |
load Image.
BadPngStream | is thrown when the Stream is corrupted. |
Reimplemented from lti::ioFunctor.
bool lti::loadPNG::checkHeader | ( | const std::string & | filename, | |
point & | imageSize, | |||
int & | bitsPerPixel, | |||
int & | imageType | |||
) |
check the data of the PNG header
filename | name of the PNG file to be tested | |
imageSize | returns the size of the PNG: imageSize.x is the number of columns and imageSize.y the numbeer of rows. | |
bitsPerPixel | number of bits per pixel | |
imageType | For color types 0 (gray) and 4 (gray-alpha), the mappings apply to the gray sample values (but not to the alpha sample). For color types 2 (RGB), 3 (indexed RGB), and 6 (RGBA), the mappings apply independently to each of the red, green, and blue sample values (but not the alpha sample). In the case of color type 3 (indexed RGB), the mapping refers to the RGB samples and not to the index values. |
virtual functor* lti::loadPNG::clone | ( | ) | const [virtual] |
returns a pointer to a clone of the functor.
Implements lti::functor.
virtual const char* lti::loadPNG::getTypeName | ( | ) | const [virtual] |
returns the name of this type
Reimplemented from lti::ioPNG.
bool lti::loadPNG::load | ( | const std::string & | filename, | |
channel8 & | theImage, | |||
lti::palette & | colors | |||
) | [virtual] |
shortcut for load PNG
Reimplemented from lti::ioFunctor.
bool lti::loadPNG::load | ( | std::ifstream & | file, | |
image & | theImage | |||
) |
method for loading a PNG image from an already opened stream.
bool lti::loadPNG::load | ( | const std::string & | filename, | |
image & | theImage | |||
) | [virtual] |
shortcut for load PNG
Reimplemented from lti::ioFunctor.