class PPalette: public PContainer

A class representing a logical palette of colours.

Inheritance:


Public Methods

[more] PPalette ()
Create a new empty palette.
[more]virtual Comparison Compare ( const PObject & obj ) const
Compare two palette objects for equality.
[more]virtual PINDEX GetSize () const
Get the current size of the palette, ie the total number of colours added to this logical palette.
[more]virtual BOOL SetSize ( PINDEX newSize )
Set the new size of the palette.
[more]PINDEX AddColour ( const PColour & colour )
Add a colour specification into the palette, if the colour already exists in the palette, no new entry is added.
[more]BOOL RemoveColour ( const PColour & colour )
Remove from the palette the colour at the specified index or of the exact RGB value specified.
[more]BOOL HasColour ( const PColour & colour ) const
Determine if the palette contains an exact match for the colour
[more]PINDEX GetIndex ( const PColour & colour ) const
Locate the index in the palette of the nearest match to the specified colour that is in the palette.
[more]PColour GetColour ( PINDEX indx ) const
Get the colour specification for the specified index value.
[more]BOOL SetColour ( PINDEX idx, const PColour & colour )
Set a colour specification into the palette at the specified index.

Public

[more] Overrides from class PObject
[more] Overrides from class PContainer
[more] New functions for class


Inherited from PContainer:

Public

Construction

Common functions for containers

Protected Methods

ovirtual void DestroyContents()
ovirtual void AssignContents(const PContainer & c)
ovoid CopyContents(const PContainer & c)
ovoid CloneContents(const PContainer * src)
ovoid Destruct()


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions

Miscellaneous functions


Documentation

A class representing a logical palette of colours.

A palette is a look up table for converting an index into a full RGB colour specification. A palette typically has a small number of colours eg 16 or 256.

o PPalette()
Create a new empty palette.

o Overrides from class PObject

ovirtual Comparison Compare( const PObject & obj ) const
Compare two palette objects for equality. The two instances must reference the same actual palette. Thay cannot be two palettes that happen to have the same colours in them.

Returns:
EqualTo if the two objects reference to the same palette, otherwise GreaterThan.
Parameters:
obj - Another palette object to compare against.

o Overrides from class PContainer

ovirtual PINDEX GetSize() const
Get the current size of the palette, ie the total number of colours added to this logical palette.

Returns:
number of colours in palette.

ovirtual BOOL SetSize( PINDEX newSize )
Set the new size of the palette. If the size was increased, all colours created between the old last colour and the new will be set to black.

Returns:
TRUE if the size was successfully changed. The value FALSE usually indicates failure due to insufficient memory.
Parameters:
newSize - New size of the palette

o New functions for class

oPINDEX AddColour( const PColour & colour )
Add a colour specification into the palette, if the colour already exists in the palette, no new entry is added. Otherwise a new entry is appended.

Returns:
index for the colour added to the palette.
Parameters:
colour - New colour to add to the palette.

oBOOL RemoveColour( const PColour & colour )
Remove from the palette the colour at the specified index or of the exact RGB value specified.

Note when a colour is removed any indexes to colours after the remove one will correspond to a different colour that before, ie all colours are moved up one entry in the palettes ärray" of colours.

Returns:
TRUE if the colour was in the palette and was removed.
Parameters:
colour - Colour to remove from the palette.

oBOOL HasColour( const PColour & colour ) const
Determine if the palette contains an exact match for the colour

Returns:
TRUE if colour is in palette.
Parameters:
colour - Colour to search for in palette.

oPINDEX GetIndex( const PColour & colour ) const
Locate the index in the palette of the nearest match to the specified colour that is in the palette.

Note that of there is more than one colour that is identical to the one being searched for, the particular matching index that is returned is not defined, it could be any one of them.

Returns:
index of nearest colour in palette.
Parameters:
colour - Colour to serarch for in palette.

oPColour GetColour( PINDEX indx ) const
Get the colour specification for the specified index value.

Returns:
colour at index in palette.
Parameters:
indx - Index of colour in palette.

oBOOL SetColour( PINDEX idx, const PColour & colour )
Set a colour specification into the palette at the specified index. If this is beyond the end of the palette the palette is expanded to accommodate the new index. All colours created between the old last colour and the new will be set to black.

Returns:
TRUE if colour was successfully added to palette.
Parameters:
idx - Index of colour in palette.
colour - New colour to set at index in palette.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.