Contents Up Previous Next

wxPalette

A palette is a table that maps pixel values to RGB colours. It allows the colours of a low-depth bitmap, for example, to be mapped to the available colours in a display.

Derived from

wxGDIObject
wxObject

Include files

<wx/palette.h>

Predefined objects

Objects:

wxNullPalette

See also

wxDC::SetPalette, wxBitmap

Members

wxPalette::wxPalette
wxPalette::~wxPalette
wxPalette::Create
wxPalette::GetPixel
wxPalette::GetRGB
wxPalette::Ok
wxPalette::operator =
wxPalette::operator ==
wxPalette::operator !=


wxPalette::wxPalette

wxPalette()

Default constructor.

wxPalette(const wxPalette& palette)

Copy constructor. This uses reference counting so is a cheap operation.

wxPalette(int n, const unsigned char* red,
const unsigned char* green, const unsigned char* blue)

Creates a palette from arrays of size n, one for each red, blue or green component.

Parameters

palette

n

red

green

blue

See also

wxPalette::Create

wxPerl note: In wxPerl the third constructor form takes as parameters 3 array references ( they must be of the same length ).


wxPalette::~wxPalette

~wxPalette()

Destructor.


wxPalette::Create

bool Create(int n, const unsigned char* red, const unsigned char* green, const unsigned char* blue)

Creates a palette from arrays of size n, one for each red, blue or green component.

Parameters

n

red

green

blue

Return value

true if the creation was successful, false otherwise.

See also

wxPalette::wxPalette


wxPalette::GetPixel

int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const

Returns a pixel value (index into the palette) for the given RGB values.

Parameters

red

green

blue

Return value

The nearest palette index.

See also

wxPalette::GetRGB


wxPalette::GetRGB

bool GetPixel(int pixel, const unsigned char* red, const unsigned char* green, const unsigned char* blue) const

Returns RGB values for a given palette index.

Parameters

pixel

red

green

blue

Return value

true if the operation was successful.

See also

wxPalette::GetPixel

wxPerl note: In wxPerl this method takes only the pixel parameter and returns a 3-element list ( or the empty list upon failure ).


wxPalette::Ok

bool Ok() const

Returns true if palette data is present.


wxPalette::operator =

wxPalette& operator =(const wxPalette& palette)

Assignment operator, using reference counting. Returns a reference to 'this'.


wxPalette::operator ==

bool operator ==(const wxPalette& palette)

Equality operator. Two palettes are equal if they contain pointers to the same underlying palette data. It does not compare each attribute, so two independently-created palettes using the same parameters will fail the test.


wxPalette::operator !=

bool operator !=(const wxPalette& palette)

Inequality operator. Two palettes are not equal if they contain pointers to different underlying palette data. It does not compare each attribute.