Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Palette Class Reference

A class to represent the color palette used with a platforms graphics port.

Inheritance diagram for CP_Palette:

CP_M_RefCounted CP_NoCopy List of all members.

Public Member Functions

virtual ~CP_Palette () throw ()
 Destructor.
Constructor / Destructor
 CP_Palette ()
 Constructor.
 CP_Palette (UInt16 inNumberColors, bool inWantSystemDefault=true, bool inWantBW=false)
 CP_Palette (SInt32 inCLUTResourceID)
Converters
UInt32 BitDepthToNumberColors (SInt16 inBitDepth)
SInt16 NumberColorsToBitDepth (UInt32 inNumberColors)
Getters
SInt16 GetCount () const
CP_RGBColor GetColorEntry (SInt16 inIndex) const
SInt16 GetColorIndex (const CP_RGBColor &inColor)
Setters
void SetColorEntry (SInt16 inIndex, const CP_RGBColor &inColor)
Constructor / Destructor
 CP_Palette (CTabHandle inColorTable)
 Constructor.
Getters
CTabHandle GetColorTable ()
Constructor / Destructor
 CP_Palette (SInt32 *inColorTable, SInt16 inNumberColors)
 Constructor.
Getters
HPALETTE GetColorTable ()

Protected Attributes

CTabHandle fColorTable
bool fFromSystem
HPALETTE fColorTable
LPLOGPALETTE fLogPalette
char * fColorTable

Private Member Functions

Misc
void MakeMacOSColorTable (UInt16 inNumberColors)
Misc
bool LoadCLUT (SInt32 inCLUTResourceID)
void CreateDefaultWinPalette (UInt16 inBitDepth)

Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_Palette::CP_Palette  ) 
 

Constructor.

Exceptions:
none 

CP_Palette::CP_Palette UInt16  inBitDepth,
bool  inWantSystemDefault = true,
bool  inWantBW = false
 

Constructor.

Parameters:
inBitDepth Bit depth of the palette, can be 1, 2, 4 or 8.
inWantSystemDefault Do we want the systems default palette.
inWantBW Do we want a black and white palette.
Exceptions:
none 

CP_Palette::CP_Palette SInt32  inCLUTResourceID  ) 
 

Constructor.

Parameters:
inCLUTResouceID The resource id of the color table to construct the palette from.
Exceptions:
none 

CP_Palette::~CP_Palette  )  throw () [virtual]
 

Destructor.

Exceptions:
none 

CP_Palette::CP_Palette CTabHandle  inColorTable  ) 
 

Linux color table.

CP_Palette::CP_Palette SInt32 inColorTable,
SInt16  inNumberColors
 

Constructor.

Parameters:
inColorTable Pointer to a Windows color palette containing the colors to construct this palette from.
inNumberColors The number of colors in the palette. If there are more than 256 colors in inNumberColors, then the first 256 colors will be used.
Exceptions:
none 


Member Function Documentation

UInt32 CP_Palette::BitDepthToNumberColors SInt16  inBitDepth  ) 
 

Return the number of colors available in the palette for the passed in bit depth.

Parameters:
inBitDepth Bit depth we are interested in, should be 1, 2, 4 or 8.
Exceptions:
none 
Returns:
void

SInt16 CP_Palette::NumberColorsToBitDepth UInt32  inNumberColors  ) 
 

Return the bit depth based upon the passed in number of colors.

Parameters:
inNumberColors The number of colors we are checking the bit depth for. If inNumberColors is greater than 256, then 0 is returned.
Exceptions:
none 
Returns:
void

SInt16 CP_Palette::GetCount  )  const
 

Return a count of the number of colors in this palette.

Exceptions:
none 
Returns:
SInt16 const The number of colors in the palette.

CP_RGBColor CP_Palette::GetColorEntry SInt16  inIndex  )  const
 

Return a CP_RGBColor for the passed in palette index. If the passed in index is not valid, then the first or last entry is returned, depending on if the index is less than 1 or greater than the number of entries.

Parameters:
inIndex 1 based index of the color to be found.
Exceptions:
CP_ThrowOutOfRange Throws an out of range exception if the index is not valid.
Returns:
CP_RGBColor const The color we are looking for.

SInt16 CP_Palette::GetColorIndex const CP_RGBColor inColor  ) 
 

Return the palette index for a given color. If there are more than 1 color with the same values, then the first one is returned. If the color can't be found, then 0 is returned.

Parameters:
inRGBColor Color that we are looking for the index of.
Exceptions:
none 
Returns:
SInt16 The returned index.

void CP_Palette::SetColorEntry SInt16  inIndex,
const CP_RGBColor inColor
 

Set a color entry for the palette.

Parameters:
inIndex Index of the color to set.
inColor CP_RGBColor to set at the passed in index.
Exceptions:
CP_ThrowOutOfRange Throws an out of range exception if the index is not valid.
Returns:
SInt16 The returned index.

CTabHandle CP_Palette::GetColorTable  ) 
 

Return a MacOS CTabHandle containing the colors in the palette.

void CP_Palette::MakeMacOSColorTable UInt16  inBitDepth  )  [private]
 

Make an empty MacOS CTabHandle color table for use in this object. All colors will be set to 0.

Parameters:
inBitDepth Bit depth of the desired color table.
Exceptions:
Memory exceptions Throws a memory failed exception if the table could not be allocated. OSError exception Throws an OSError exception if there was a memory manager error.
Returns:
void

HPALETTE CP_Palette::GetColorTable  ) 
 

Return the Windows color table.

bool CP_Palette::LoadCLUT SInt32  inCLUTResourceID  )  [private]
 

Private routine to load the colors from a CLUT resource under Windows.

Parameters:
inCLUTResourceID Id of the resource holding the color table.
Exceptions:
none 
Returns:
bool Returns true if successful.

void CP_Palette::CreateDefaultWinPalette UInt16  inBitDepth  )  [private]
 

Creates a default Windows palettes of the passed in bit depth.

Parameters:
inBitDepth Bit depth of the desired color table.
Exceptions:
none 
Returns:
void

UInt32 CP_M_RefCounted::AddReference  )  const [inherited]
 

Add a reference to our object, returning the new reference count.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

UInt32 CP_M_RefCounted::RemoveReference  )  const [inherited]
 

Remove a reference to our object, returning the new reference count. If the count is 0, then this object is also deleted, and 0 is returned.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

void CP_M_RefCounted::Autorelease  )  const [inherited]
 

Add the object to the topmost auto-release pool. This will ensure that the object is eventually released.

See also:
CP_AutoReleasePool
Exceptions:
none 
Returns:
void

UInt32 CP_M_RefCounted::GetRefCount  )  const [inherited]
 

Returns the current ref count.

Exceptions:
none 
Returns:
UInt32 The current referencce count.


Member Data Documentation

CTabHandle CP_Palette::fColorTable [protected]
 

bool CP_Palette::fFromSystem [protected]
 

A MacOS CTabHandle containing the colors.

HPALETTE CP_Palette::fColorTable [protected]
 

A MacOS CTabHandle containing the colors.

LPLOGPALETTE CP_Palette::fLogPalette [protected]
 

Windows color table.

char* CP_Palette::fColorTable [protected]
 

Window palette.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:55 2005 for CPLAT by  doxygen 1.4.0