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)
 CP_Palette (CTabHandle inColorTable)
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)
CTabHandle GetColorTable ()
Setters
void SetColorEntry (SInt16 inIndex, const CP_RGBColor &inColor)

Protected Attributes

CTabHandle fColorTable
bool fFromSystem

Private Member Functions

Misc
void MakeMacOSColorTable (UInt16 inNumberColors)

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 CTabHandle  inColorTable  ) 
 

Set the palette from the passed in color table handle

Parameters:
inColorTable MacOS CTabHandle of the color palette.
Exceptions:
none 

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

Destructor.

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.

CTabHandle CP_Palette::GetColorTable  ) 
 

Return a MacOS CTabHandle containing the colors in the palette.

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.

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

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.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:54 2005 for CPLAT_MacOS by  doxygen 1.4.0