![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
Functor to read a bitmap (BMP) file. More...
#include <ltiBMPFunctor.h>
Public Member Functions | |
loadBMP () | |
~loadBMP () | |
virtual const char * | getTypeName () const |
bool | apply (image &theImage) |
bool | apply (channel8 &theChannel, lti::palette &colors) |
bool | apply (channel &theChannel) |
int | apply (image &theImage, 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 &theChannel, lti::palette &colors) |
bool | load (const std::string &filename, channel &theChannel) |
int | load (const std::string &filename, image &theImage, channel8 &theChannel, lti::palette &colors) |
bool | checkHeader (const std::string &filename, point &imageSize, int &bitsPerPixel, int &colorEntries) |
virtual functor * | clone () const |
Functor to read a bitmap (BMP) 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 you need to read or write many BMPs at the same time, use in each thread an instance of this functor, or protect your code with semaphores.
lti::loadBMP::loadBMP | ( | ) |
default constructor
lti::loadBMP::~loadBMP | ( | ) | [inline] |
destructor
int lti::loadBMP::apply | ( | image & | theImage, | |
channel8 & | theChannel, | |||
lti::palette & | colors | |||
) | [virtual] |
this method loads an image or a channel8, depending on the contents of the file header.
if the number of bits per pixel is 24, the image will be initialized, if the number of bits is less or equal 8, the channel and palette will be initialized.
If the file contains an indexed image, the palette will contain the corresponding colors. If the file containes a "true color" image, the palette will have size 0.
theImage | if the file contains a 24-bit image, this parameter will be initialized | |
theChannel | if the channel contains an 8-bit image, this parameters will contain the readed data | |
colors | if the channel was loaded this parameter will contain the used colors. |
Reimplemented from lti::ioFunctor.
bool lti::loadBMP::apply | ( | channel & | theChannel | ) |
bool lti::loadBMP::apply | ( | channel8 & | theChannel, | |
lti::palette & | colors | |||
) | [virtual] |
load channel
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
theChannel | the image on the file will be loaded here | |
colors | theChannel contains just indexes to the pixel values in this vector. |
Reimplemented from lti::ioFunctor.
bool lti::loadBMP::apply | ( | image & | theImage | ) | [virtual] |
load Image
theImage | the file specified in the parameters will be loaded in this image. Note that independently of the soft of image in the file, this will always be converted to a color lti::image. |
Reimplemented from lti::ioFunctor.
bool lti::loadBMP::checkHeader | ( | const std::string & | filename, | |
point & | imageSize, | |||
int & | bitsPerPixel, | |||
int & | colorEntries | |||
) |
check the data of the bitmap header
filename | name of the bitmap file to be tested | |
imageSize | returns the size of the bitmap: imageSize.x is the number of columns and imageSize.y the numbeer of rows. | |
bitsPerPixel | number of bits per pixel | |
colorEntries | number of color entries in the palette (only used if bitsPerPixel<=8 |
virtual functor* lti::loadBMP::clone | ( | ) | const [virtual] |
returns a pointer to a clone of the functor.
Implements lti::functor.
virtual const char* lti::loadBMP::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("loadBMP")
Reimplemented from lti::ioBMP.
int lti::loadBMP::load | ( | const std::string & | filename, | |
image & | theImage, | |||
channel8 & | theChannel, | |||
lti::palette & | colors | |||
) |
this method loads an image or a channel8, depending on the contents of the file header.
if the number of bits per pixel is 24, the image will be initialized, if the number of bits is less or equal 8, the channel and palette will be initialized.
The wrong type will be resized to (0,0)
filename | name of the file to be readed | |
theImage | if the file contains a 24bit color image, this parameter will be resized and initialized with the contents of the file | |
theChannel | if the file contains a 8bit or less indexed image, this parameter and the palette will be initialized with the contents of the file. | |
colors | the color palette for the indexed image. |
bool lti::loadBMP::load | ( | const std::string & | filename, | |
channel & | theChannel | |||
) |
bool lti::loadBMP::load | ( | const std::string & | filename, | |
channel8 & | theChannel, | |||
lti::palette & | colors | |||
) | [virtual] |
shortcut for load BMP.
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
filename | name of the file to be readed | |
theChannel | variable where the image will be stored | |
colors | the palette used will be stored here |
Reimplemented from lti::ioFunctor.
bool lti::loadBMP::load | ( | std::ifstream & | file, | |
image & | theImage | |||
) |
shortcut for load BMP
file | an already opened stream for reading binary data | |
theImage | variable where the image will to be stored |
bool lti::loadBMP::load | ( | const std::string & | filename, | |
image & | theImage | |||
) | [virtual] |
shortcut for load BMP
filename | name of the file to be readed | |
theImage | variable where the image will to be stored |
Reimplemented from lti::ioFunctor.