LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::loadBMP Class Reference

Functor to read a bitmap (BMP) file. More...

#include <ltiBMPFunctor.h>

Inheritance diagram for lti::loadBMP:
Inheritance graph
[legend]
Collaboration diagram for lti::loadBMP:
Collaboration graph
[legend]

List of all members.

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 functorclone () const

Detailed Description

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.


Constructor & Destructor Documentation

lti::loadBMP::loadBMP (  ) 

default constructor

lti::loadBMP::~loadBMP (  )  [inline]

destructor


Member Function Documentation

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.

Parameters:
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.
Returns:
the number of bits per pixel of the loaded image or 0 if an error occured. The valid values are 1, 4, 8, or 24

Reimplemented from lti::ioFunctor.

bool lti::loadBMP::apply ( channel theChannel  ) 

load channel

Use this method if you know that the file contains a gray valued image.

Parameters:
theChannel the image on the file will be loaded here
Returns:
true if successful, false otherwise.
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.

Parameters:
theChannel the image on the file will be loaded here
colors theChannel contains just indexes to the pixel values in this vector.
Returns:
true if successful, false otherwise.

Reimplemented from lti::ioFunctor.

bool lti::loadBMP::apply ( image theImage  )  [virtual]

load Image

Parameters:
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.
Returns:
a reference to the loaded 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

Parameters:
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
Returns:
true if file is ok
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)

Parameters:
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.
Returns:
the number of bits per pixel of the loaded image or 0 if an error occured. The valid values are 1, 4, 8, or 24
bool lti::loadBMP::load ( const std::string &  filename,
channel theChannel 
)

shortcut for load BMP.

Use this method if you know that the file contains a gray valued image.

Parameters:
filename name of the file to be readed
theChannel variable where the image will be stored
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.

Parameters:
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

Parameters:
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

Parameters:
filename name of the file to be readed
theImage variable where the image will to be stored

Reimplemented from lti::ioFunctor.


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

Generated on Sat Apr 10 15:28:00 2010 for LTI-Lib by Doxygen 1.6.1