#include <CImageLoader.h>
Public Member Functions | |
cImageLoader () | |
Default constructor of cImageLoader; doesn't load anything... | |
cImageLoader (const char *filename) | |
Default constructor of cImageLoader; loads the specified filename... | |
virtual | ~cImageLoader () |
Destructor of cImageLoader. | |
unsigned char * | getData () |
Get a pointer to the actual image data... use with care... | |
unsigned int | getWidth () |
Get width of image. | |
unsigned int | getHeight () |
Get height of image. | |
unsigned int | getFormat () |
Get the format (GL_RGB or GL_RGBA) of the image. | |
unsigned int | getBitsPerPixel () |
Get the number of bits per pixel used to store this image. | |
cColorb | getPixelColor (const unsigned int a_x, const unsigned int a_y) |
Get the color of a pixel by passing its x and y coordinate. | |
void | setPixelColor (const unsigned int a_x, const unsigned int a_y, const cColorb &a_color) |
Set the color of a pixel. | |
void | clear (const cColorb &a_color) |
Clear an image with defined color. | |
void | replace (const cColorb &a_oldColor, const cColorb &a_newColor) |
Replace a specific color in the image by a new one. | |
void | allocate (const unsigned int a_width, const unsigned int a_height) |
Allocate a new image by defining its size. | |
unsigned int | initialized () |
Returns 1 if a file has been successfully loaded, 0 otherwise. | |
bool | loadFromFile (const char *filename) |
Load image file by passing image path and name as argument. | |
bool | loadFromFileOLE (const char *szPathName) |
For windows systems we can use the OLE loader if we don't have a native loaders. | |
const char * | getFilename () const |
Get the filename from which this image was loaded. | |
Protected Member Functions | |
void | defaults () |
Initialize member variables. | |
void | cleanup () |
Delete memory and rid ourselves of any image we had previously stored. | |
void | convertToRGBA () |
All images are converted from their native format to RGBA by this class. | |
Protected Attributes | |
char | m_filename [CHAI_SIZE_PATH] |
The last image filename that I loaded. | |
int | m_width |
Width in pixels of the current image. | |
int | m_height |
Height in pixels of the current image. | |
unsigned int | m_format |
Either GL_RGB or GL_RGBA. | |
unsigned int | m_bits_per_pixel |
Basically always 8... | |
unsigned char * | m_data |
The image data itself. | |
bool | m_initialized |
Have I actually loaded a valid image? |
cImageLoader::cImageLoader | ( | ) |
Default constructor of cImageLoader; doesn't load anything...
Default constructor of cImageLoader
cImageLoader::cImageLoader | ( | const char * | a_filename | ) |
Default constructor of cImageLoader; loads the specified filename...
Constructor of cImageLoader; loads the specified file. Currently 24-bit .bmp and 32-bit .tga files are supported.
Use the initialized() function to determine whether loading was successful.
a_filename | Image filename |
cImageLoader::~cImageLoader | ( | ) | [virtual] |
Destructor of cImageLoader.
Destructor of cImageLoader
void cImageLoader::allocate | ( | const unsigned int | a_width, | |
const unsigned int | a_height | |||
) |
Allocate a new image by defining its size.
Allocate a new image by defining its size.
a_width | Width of new image | |
a_height | Height of new image |
void cImageLoader::clear | ( | const cColorb & | a_color | ) |
Clear an image with defined color.
Clear an image with a defined color
a_color | new color of the image |
void cImageLoader::convertToRGBA | ( | ) | [protected] |
All images are converted from their native format to RGBA by this class.
Convert image to OpenGL-compatible RGBA format
void cImageLoader::defaults | ( | ) | [protected] |
Initialize member variables.
Initialize internal variables
Free memory that was used for image data, and re-initialize internal variables.
cColorb cImageLoader::getPixelColor | ( | const unsigned int | a_x, | |
const unsigned int | a_y | |||
) |
Get the color of a pixel by passing its x and y coordinate.
Get the color of a pixel by passing its x and y coordinate
a_x | X coordinate of the pixel | |
a_y | Y coordinate of the pixel |
bool cImageLoader::loadFromFile | ( | const char * | a_filename | ) |
Load image file by passing image path and name as argument.
Loads this image from the specified file. Returns 0 if all goes well, <0 for an error. Note that regardless of whether it succeeds, this over-writes any image that had previously been loaded by this object.
Always converts the resulting image to RGBA.
a_filename | Image filename |
bool cImageLoader::loadFromFileOLE | ( | const char * | szPathName | ) |
For windows systems we can use the OLE loader if we don't have a native loaders.
Load an Image file using windows loader.
szPathName | filename |
Replace a specific color in the image by a new one.
Replace a specific color in the image by a new one
a_oldColor | Old color to be replaced | |
a_newColor | New color that shall replace the old one |
void cImageLoader::setPixelColor | ( | const unsigned int | a_x, | |
const unsigned int | a_y, | |||
const cColorb & | a_color | |||
) |
Set the color of a pixel.
Set the color of a pixel
a_x | X coordinate of the pixel | |
a_y | Y coordinate of the pixel | |
a_color | new color of the pixel |