Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members

# ptc::Palette Class Reference

A palette of color entries. More...

List of all members.

## Public Members

- Palette ()
- Palette (const int32 data[])
- Palette (const Palette &palette)
- ~Palette ()
- int32* lock ()
- void unlock ()
- void load (const int32 data[])
- void save (int32 data[]) const
- const int32* data () const
- Palette& operator= (const Palette &palette)
- bool operator== (const Palette &palette) const
- bool operator!= (const Palette &palette) const

## Detailed Description

A palette of color entries.

The palette class represents a 256 color palette for 8 bit indexed color formats.

Internally each palette object maintains an array of 256 32 bit integer color values packed in ARGB8888 format.

Palette objects are typically used to set the surface palette with Surface::palette(const Palette &palette).

They are also used, although less frequently, to load and save surface pixels with Surface::load() and Surface::save().

And, even less frequently, they are used with the low level pixel copying and conversion routine Copy::palette().

## Member Function Documentation

### ptc::Palette::Palette ()

Default constructor.

All palette color entries are set to black.

### ptc::Palette::Palette (const int32 data[])

Creates a palette object with its color entries set to the color values in data.

The data array is an array of r,g,b,a color values packed into a 32 bit integer in the format ARGB8888.

Parameters:
  data - the palette data.

### ptc::Palette::Palette (const Palette & palette)

Copy constructor.

### ptc::Palette::~Palette ()

Frees all palette memory and checks if the palette is still locked.

Exceptions:
  An - Error exception is thrown if the palette is still locked.

### int32 * ptc::Palette::lock ()

Gets a pointer to the palette data array.

The data array is an array of r,g,b,a color values packed into a 32 bit integer in the format ARGB8888.

Each successful palette lock must be accompanied by an unlock.

Only one lock is allowed on a palette object at any one time.

Returns:
  a pointer to the palette data.

Exceptions:
  An - Error exception is thrown on failure.

### void ptc::Palette::unlock ()

Unlocks the palette color data after a call to lock.

If unlock is called and the palette is not locked a ptc::Error exception will be thrown.

Exceptions:
  An - Error exception is thrown on failure.

### void ptc::Palette::load (const int32 data[])

Loads the color values from data to the palette.

The data array is an array of r,g,b,a color values packed into a 32 bit integer in the format ARGB8888.

Parameters:
  data - the palette data.

### void ptc::Palette::save (int32 data[]) const

Saves the palette color values to the color array data.

The data array is an array of r,g,b,a color values packed into a 32 bit integer in the format ARGB8888.

Parameters:
  data - the palette data.

### const int32 * ptc::Palette::data () const

Gets a read-only pointer to the palette data array.

The data array is an array of r,g,b,a color values packed into a 32 bit integer in the format ARGB8888.

Returns:
  a pointer to the palette data.

### Palette & ptc::Palette::operator= (const Palette & palette)

Assignment operator.

### bool ptc::Palette::operator== (const Palette & palette) const

Equality operator.

### bool ptc::Palette::operator!= (const Palette & palette) const

Inequality operator.

The documentation for this class was generated from the following file:

- ptc.h