Forums
This is the online documentation for Colossus Entertainments Pixie Game Engine

Alphamap Class Reference
[Graphics]

List of all members.


Detailed Description

Uncompressed 8-bit alpha channel.

Author:
Mattias Gustavsson
An Alphamap is simply a collection of 8-bit alpha values with a width and a height.

Definition at line 25 of file Alphamap.h.


Public Types

enum  Orientation {
  Rotate_0, Rotate_90, Rotate_180, Rotate_270,
  Mirror_X, Mirror_Y, Orientations_Count
}

Public Member Functions

 Alphamap ()
 Alphamap (const Asset &asset)
 Alphamap (int width, int height)
 Alphamap (const Image &image)
 ~Alphamap ()
void SetPixel (int x, int y, unsigned char alpha)
unsigned char GetPixel (int x, int y) const
unsigned char GetPixel (int x, int y, Orientation orientation) const
unsigned char * GetData () const
int GetWidth (Orientation orientation=Rotate_0) const
int GetHeight (Orientation orientation=Rotate_0) const
void Save (Asset &asset)
void Load (const Asset &asset)
void WriteToAsset (Asset *asset)
void ReadFromAsset (const Asset *asset)

Public Attributes

unsigned char * alpha_
 Pixel alpha data (width*height).
int width_
 Width of the bitmap.
int height_
 Height of the bitmap.

Member Enumeration Documentation

Sometimes it is useful to rotate or flip bitmaps. The methods specified below all take an Orientation parameter, which will cause the method to function as if the bitmap was transformed in the manner specified, without actually transforming any pixel data. This means you can blit an image upside down by just passing Mirror_Y as the orientation parameter to the blit method. All the orientation parameters default to 0 degree rotation, which means untransformed, so just omit the parameter if you don't want to think about orientations...

Enumerator:
Rotate_0  The bitmap is not transformed.
Rotate_90  The bitmap is rotated 90 degrees clockwise.
Rotate_180  The bitmap is rotated 180 degrees.
Rotate_270  The bitmap is rotated 270 degrees clockwise / 90 degrees counter clockwise.
Mirror_X  The bitmap is flipped horizontally.
Mirror_Y  The bitmap is flipped vertically.
Orientations_Count  Number of available orientations, handy if you want to pick a random one.

Definition at line 54 of file Alphamap.h.


Constructor & Destructor Documentation

Alphamap::Alphamap (  ) 

Definition at line 14 of file Alphamap.cpp.

Alphamap::Alphamap ( const Asset asset  ) 

Definition at line 24 of file Alphamap.cpp.

Alphamap::Alphamap ( int  width,
int  height 
)

Definition at line 35 of file Alphamap.cpp.

Alphamap::Alphamap ( const Image image  ) 

Parameters:
image  Image to create bitmap from

Definition at line 47 of file Alphamap.cpp.

Alphamap::~Alphamap (  ) 

Definition at line 70 of file Alphamap.cpp.


Member Function Documentation

void Alphamap::SetPixel ( int  x,
int  y,
unsigned char  alpha 
)

Changes the pixel at the specified coordinate of the alphamap.

Parameters:
x  X-coordinate of pixel to set
y  Y-coordinate of pixel to set
alpha  8 bit alpha vallue to set the specified coordinate to

Definition at line 139 of file Alphamap.cpp.

unsigned char Alphamap::GetPixel ( int  x,
int  y 
) const

Parameters:
x  X-coordinate of pixel to get
y  Y-coordinate of pixel to get

Definition at line 147 of file Alphamap.cpp.

unsigned char Alphamap::GetPixel ( int  x,
int  y,
Orientation  orientation 
) const

Parameters:
x  X-coordinate of pixel to get
y  Y-coordinate of pixel to get
orientation  Specifies the desired transformation to use for this operation

Definition at line 155 of file Alphamap.cpp.

unsigned char * Alphamap::GetData (  )  const

Definition at line 81 of file Alphamap.cpp.

int Alphamap::GetWidth ( Orientation  orientation = Rotate_0  )  const

Gets the width of the bitmap

Returns:
The width of the bitmap in pixels
Parameters:
orientation  Specifies the desired transformation to use for this operation

Definition at line 89 of file Alphamap.cpp.

int Alphamap::GetHeight ( Orientation  orientation = Rotate_0  )  const

Gets the height of the bitmap

Returns:
The height of the bitmap in pixels
Parameters:
orientation  Specifies the desired transformation to use for this operation

Definition at line 114 of file Alphamap.cpp.

void Alphamap::Save ( Asset asset  ) 

Definition at line 212 of file Alphamap.cpp.

void Alphamap::Load ( const Asset asset  ) 

Definition at line 227 of file Alphamap.cpp.

void Alphamap::WriteToAsset ( Asset asset  ) 

Definition at line 260 of file Alphamap.cpp.

void Alphamap::ReadFromAsset ( const Asset asset  ) 

Definition at line 246 of file Alphamap.cpp.


Member Data Documentation

unsigned char* Alphamap::alpha_

Pixel alpha data (width*height).

Definition at line 125 of file Alphamap.h.

Width of the bitmap.

Definition at line 126 of file Alphamap.h.

Height of the bitmap.

Definition at line 127 of file Alphamap.h.