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

AlphaBitmap Class Reference
[Graphics]

List of all members.


Detailed Description

Uncompressed 16-bit color buffer with alpha channel.

Author:
Mattias Gustavsson
An AlphaBitmap is simply a collection of 16-bit color values with a width and a height, plus a collection of 8-bit alpha values with the same dimesnsions.

Todo:
Optimize the Blit method (split into several specialized ones, to reduce conditionals in the inner loop)

Definition at line 26 of file AlphaBitmap.h.


Public Types

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

Public Member Functions

 AlphaBitmap ()
 AlphaBitmap (const Asset &asset)
 AlphaBitmap (int width, int height)
 AlphaBitmap (const Image &image)
 ~AlphaBitmap ()
unsigned short GetPixelColor (int x, int y) const
unsigned char GetPixelAlpha (int x, int y) const
unsigned short GetPixelColor (int x, int y, Orientation orientation) const
unsigned char GetPixelAlpha (int x, int y, Orientation orientation) const
unsigned short * GetColorData () const
unsigned char * GetAlphaData () const
int GetWidth (Orientation orientation=Rotate_0) const
int GetHeight (Orientation orientation=Rotate_0) const
void Blit (Bitmap *target, int tx1, int ty1, int tx2, int ty2, unsigned short modulate=0xffff, unsigned char alpha=255) const
void Blit (int sx1, int sy1, int sx2, int sy2, Bitmap *target, int tx1, int ty1, int tx2, int ty2, unsigned short modulate=0xffff, unsigned char alpha=255) const
void Save (Asset &asset)
void Load (const Asset &asset)
void WriteToAsset (Asset *asset)
void ReadFromAsset (const Asset *asset)

Public Attributes

unsigned short * color_
 Pixel color data (width*height).
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 55 of file AlphaBitmap.h.


Constructor & Destructor Documentation

AlphaBitmap::AlphaBitmap (  ) 

Definition at line 13 of file AlphaBitmap.cpp.

AlphaBitmap::AlphaBitmap ( const Asset asset  ) 

Definition at line 24 of file AlphaBitmap.cpp.

AlphaBitmap::AlphaBitmap ( int  width,
int  height 
)

Definition at line 36 of file AlphaBitmap.cpp.

AlphaBitmap::AlphaBitmap ( const Image image  ) 

Parameters:
image  Image to create bitmap from

Definition at line 51 of file AlphaBitmap.cpp.

AlphaBitmap::~AlphaBitmap (  ) 

Definition at line 77 of file AlphaBitmap.cpp.


Member Function Documentation

unsigned short AlphaBitmap::GetPixelColor ( int  x,
int  y 
) const

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

Definition at line 158 of file AlphaBitmap.cpp.

unsigned char AlphaBitmap::GetPixelAlpha ( int  x,
int  y 
) const

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

Definition at line 166 of file AlphaBitmap.cpp.

unsigned short AlphaBitmap::GetPixelColor ( 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 174 of file AlphaBitmap.cpp.

unsigned char AlphaBitmap::GetPixelAlpha ( 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 183 of file AlphaBitmap.cpp.

unsigned short * AlphaBitmap::GetColorData (  )  const

Definition at line 92 of file AlphaBitmap.cpp.

unsigned char * AlphaBitmap::GetAlphaData (  )  const

Definition at line 100 of file AlphaBitmap.cpp.

int AlphaBitmap::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 108 of file AlphaBitmap.cpp.

int AlphaBitmap::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 133 of file AlphaBitmap.cpp.

void AlphaBitmap::Blit ( Bitmap target,
int  tx1,
int  ty1,
int  tx2,
int  ty2,
unsigned short  modulate = 0xffff,
unsigned char  alpha = 255 
) const

Definition at line 192 of file AlphaBitmap.cpp.

void AlphaBitmap::Blit ( int  sx1,
int  sy1,
int  sx2,
int  sy2,
Bitmap target,
int  tx1,
int  ty1,
int  tx2,
int  ty2,
unsigned short  modulate = 0xffff,
unsigned char  alpha = 255 
) const

This method will blit a section of this bitmap onto the target bitmap at the specified coordinate. You specify the top-left and bottom-right coordinates of a rectangle you want to blit onto the target. Clipping will be performed on the parts which are outside of the target.

Parameters:
sx1  X-coordinate for the top-left corner of the section of this bitmap which is to be blitted onto the target
sy1  Y-coordinate for the top-left corner of the section of this bitmap which is to be blitted onto the target
sx2  X-coordinate for the bottom-right corner of the section of this bitmap which is to be blitted onto the target
sy2  Y-coordinate for the bottom-right corner of the section of this bitmap which is to be blitted onto the target
target  Target bitmap to blit this bitmap onto
tx1  X-coordinate in the target bitmap. The top left corner of the blitted section will be drawn at this coordinate on the target bitmap
ty1  Y-coordinate in the target bitmap. The top left corner of the blitted section will be drawn at this coordinate on the target bitmap
modulate  16 bit color value (R5G6B5) to modulate the source pixels with before they are written.
alpha  Level of transparency the bitmap will be written with. 0=Fully transparent, 255=Fully Opaque

Definition at line 200 of file AlphaBitmap.cpp.

void AlphaBitmap::Save ( Asset asset  ) 

Definition at line 365 of file AlphaBitmap.cpp.

void AlphaBitmap::Load ( const Asset asset  ) 

Definition at line 380 of file AlphaBitmap.cpp.

void AlphaBitmap::WriteToAsset ( Asset asset  ) 

Definition at line 415 of file AlphaBitmap.cpp.

void AlphaBitmap::ReadFromAsset ( const Asset asset  ) 

Definition at line 399 of file AlphaBitmap.cpp.


Member Data Documentation

unsigned short* AlphaBitmap::color_

Pixel color data (width*height).

Definition at line 152 of file AlphaBitmap.h.

unsigned char* AlphaBitmap::alpha_

Pixel alpha data (width*height).

Definition at line 153 of file AlphaBitmap.h.

Width of the bitmap.

Definition at line 154 of file AlphaBitmap.h.

Height of the bitmap.

Definition at line 155 of file AlphaBitmap.h.