Cafu Engine
BitmapT Struct Reference

This class represents a RGBA bitmap. More...

#include "Bitmap.hpp"

Classes

class  LoadErrorT
 

Public Member Functions

 BitmapT ()
 Constructor that creates an empty bitmap. More...
 
 BitmapT (const char *FileName)
 Constructor that creates a bitmap from the file 'FileName'. More...
 
 BitmapT (unsigned int Width, unsigned int Height, const uint32_t *Buffer=NULL)
 Constructor that creates a bitmap from the memory pointed to by 'Buffer'. More...
 
void GetPixel (unsigned int x, unsigned int y, int &r, int &g, int &b) const
 These methods return and accept values in the range from 0 to 255. More...
 
void SetPixel (unsigned int x, unsigned int y, int r, int g, int b)
 
void GetPixel (unsigned int x, unsigned int y, int &r, int &g, int &b, int &a) const
 
void SetPixel (unsigned int x, unsigned int y, int r, int g, int b, int a)
 
void GetPixel (unsigned int x, unsigned int y, float &r, float &g, float &b) const
 These methods return and accept values in the range from 0.0 to 1.0. More...
 
void SetPixel (unsigned int x, unsigned int y, float r, float g, float b)
 
void GetPixel (unsigned int x, unsigned int y, float &r, float &g, float &b, float &a) const
 
void SetPixel (unsigned int x, unsigned int y, float r, float g, float b, float a)
 
void ApplyGamma (float Gamma)
 This method applies the gamma value 'Gamma' to this bitmap. More...
 
void Scale (unsigned int NewSizeX, unsigned int NewSizeY)
 Scales the bitmap to the new dimensions NewSizeX and NewSizeY. More...
 
char * GetPalettedImage () const
 This functions computes a paletted (8 BPP) image from this bitmap, using the NeuQuant Neural-Net quantization algorithm (c) by Anthony Dekker, 1994. More...
 
bool SaveToDisk (const char *FileName) const
 Writes the contents of this bitmap into a file with name 'FileName'. More...
 

Static Public Member Functions

static BitmapT GetBuiltInFileNotFoundBitmap ()
 Named constructor which returns a built-in "?FILE NOT FOUND" bitmap. More...
 

Public Attributes

unsigned int SizeX
 
unsigned int SizeY
 
ArrayT< uint32_t > Data
 

Detailed Description

This class represents a RGBA bitmap.

Constructor & Destructor Documentation

BitmapT::BitmapT ( )

Constructor that creates an empty bitmap.

BitmapT::BitmapT ( const char *  FileName)

Constructor that creates a bitmap from the file 'FileName'.

The file format is automatically determined (only!) by looking at the suffix of 'FileName'. Currently supported file formats are BMP (Windows Bitmaps), TGA (TrueVision Targa), JPG (JPEG) and PNG (Portable Network Graphics). A 'LoadErrorT' exception is thrown if the bitmap could not be loaded for any reason, including file not found errors, unsupported file formats, or unsupported sub-file formats (like paletted Windows bitmaps).

Note that the Cafu file system (cf::FileSys) is used to load the image! That means that an appropriate file system must be mounted in order to be able to create/load an image.

BitmapT::BitmapT ( unsigned int  Width,
unsigned int  Height,
const uint32_t *  Buffer = NULL 
)

Constructor that creates a bitmap from the memory pointed to by 'Buffer'.

Member Function Documentation

void BitmapT::ApplyGamma ( float  Gamma)

This method applies the gamma value 'Gamma' to this bitmap.

BitmapT BitmapT::GetBuiltInFileNotFoundBitmap ( )
static

Named constructor which returns a built-in "?FILE NOT FOUND" bitmap.

char * BitmapT::GetPalettedImage ( ) const

This functions computes a paletted (8 BPP) image from this bitmap, using the NeuQuant Neural-Net quantization algorithm (c) by Anthony Dekker, 1994.

See "Kohonen neural networks for optimal colour quantization" in "Network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of the algorithm. See also http://members.ozemail.com.au/~dekker/NEUQUANT.HTML The returned pointer contains 256*3 palette bytes (256 RGB color triples), followed by 'SizeX*SizeY' bytes of image indices into the palette. It is the callers responsibility to call 'delete[]' on the returned pointer.

void BitmapT::GetPixel ( unsigned int  x,
unsigned int  y,
int &  r,
int &  g,
int &  b 
) const

These methods return and accept values in the range from 0 to 255.

The SetPixel() method will clamp to this range if necessary.

void BitmapT::GetPixel ( unsigned int  x,
unsigned int  y,
float &  r,
float &  g,
float &  b 
) const

These methods return and accept values in the range from 0.0 to 1.0.

The SetPixel() method will clamp to this range if necessary.

bool BitmapT::SaveToDisk ( const char *  FileName) const

Writes the contents of this bitmap into a file with name 'FileName'.

The file format is automatically determined by looking at the suffix of 'FileName'. Currently supported file formats are BMP (Windows Bitmaps), JPG (JPEG) and PNG (Portable Network Graphics). NOTE: When saving the bitmap in BMP or JPG file format, the alpha channel is lost! Returns 'true' on success, 'false' on failure. Reasons for failure include unknown file formats (e.g. passing "hello.tga" for 'FileName'), and problems with the file itself (like invalid path, no disk space left, and so on).

void BitmapT::Scale ( unsigned int  NewSizeX,
unsigned int  NewSizeY 
)

Scales the bitmap to the new dimensions NewSizeX and NewSizeY.

You may specify 0 for NewSizeX or NewSizeY in order to keep that direction unchanged.


The documentation for this struct was generated from the following files: