Version: 2.9.4
Public Member Functions
wxPalette Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/palette.h>

Inheritance diagram for wxPalette:

Detailed Description

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. The notion of palettes is becoming more and more obsolete nowadays and only the MSW port is still using a native palette. All other ports use generic code which is basically just an array of colours.

It is likely that in the future the only use for palettes within wxWidgets will be for representing colour indeces from images (such as GIF or PNG). The image handlers for these formats have been modified to create a palette if there is such information in the original image file (usually 256 or less colour images). See wxImage for more information.

Library:  wxCore
Category:  Graphics Device Interface (GDI)

Predefined objects/pointers: wxNullPalette

参照:
wxDC::SetPalette(), wxBitmap

Public Member Functions

 wxPalette ()
 Default constructor.
 wxPalette (const wxPalette &palette)
 Copy constructor, uses Reference Counting.
 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.
virtual ~wxPalette ()
 Destructor.
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.
virtual int GetColoursCount () const
 Returns number of entries in palette.
int GetPixel (unsigned char red, unsigned char green, unsigned char blue) const
 Returns a pixel value (index into the palette) for the given RGB values.
bool GetRGB (int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const
 Returns RGB values for a given palette index.
virtual bool IsOk () const
 Returns true if palette data is present.
wxPaletteoperator= (const wxPalette &palette)
 Assignment operator, using Reference Counting.

List of all members.


Constructor & Destructor Documentation

wxPalette::wxPalette ( )

Default constructor.

wxPalette::wxPalette ( const wxPalette palette)

Copy constructor, uses Reference Counting.

Parameters:
paletteA reference to the palette to copy.
wxPalette::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:
nThe number of indices in the palette.
redAn array of red values.
greenAn array of green values.
blueAn array of blue values.

wxPerl Note: In wxPerl this method takes as parameters 3 array references (they must be of the same length).

参照:
Create()
virtual wxPalette::~wxPalette ( ) [virtual]

Member Function Documentation

bool wxPalette::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:
nThe number of indices in the palette.
redAn array of red values.
greenAn array of green values.
blueAn array of blue values.
Returns:
true if the creation was successful, false otherwise.
参照:
wxPalette()
virtual int wxPalette::GetColoursCount ( ) const [virtual]

Returns number of entries in palette.

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

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

Parameters:
redRed value.
greenGreen value.
blueBlue value.
Returns:
The nearest palette index or wxNOT_FOUND for unexpected errors.
参照:
GetRGB()
bool wxPalette::GetRGB ( int  pixel,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue 
) const

Returns RGB values for a given palette index.

Parameters:
pixelThe palette index.
redReceives the red value.
greenReceives the green value.
blueReceives the blue value.
Returns:
true if the operation was successful.

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

参照:
GetPixel()
virtual bool wxPalette::IsOk ( ) const [virtual]

Returns true if palette data is present.

wxPalette& wxPalette::operator= ( const wxPalette palette)

Assignment operator, using Reference Counting.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines