2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: palette.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxPalette
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxPalette
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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
|
2008-03-08 14:43:31 +00:00
|
|
|
colours.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@stdobjects
|
2008-04-06 12:52:58 +00:00
|
|
|
::wxNullPalette
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-06 12:52:58 +00:00
|
|
|
@see wxDC::SetPalette(), wxBitmap
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxPalette : public wxGDIObject
|
|
|
|
{
|
|
|
|
public:
|
2008-04-06 12:52:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxPalette();
|
2008-04-06 15:28:55 +00:00
|
|
|
|
2008-04-06 12:52:58 +00:00
|
|
|
/**
|
|
|
|
Copy constructor, uses @ref overview_refcount.
|
2008-10-10 19:14:22 +00:00
|
|
|
|
|
|
|
@param palette
|
|
|
|
A reference to the palette to copy.
|
2008-04-06 12:52:58 +00:00
|
|
|
*/
|
|
|
|
wxPalette(const wxPalette& palette);
|
2008-04-06 15:28:55 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2008-04-06 15:28:55 +00:00
|
|
|
Creates a palette from arrays of size @a n, one for each red, blue or
|
2008-04-06 12:52:58 +00:00
|
|
|
green component.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
The number of indices in the palette.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param red
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of red values.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param green
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of green values.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param blue
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of blue values.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Create()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxPalette(int n, const unsigned char* red,
|
|
|
|
const unsigned char* green,
|
|
|
|
const unsigned char* blue);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-04-06 12:52:58 +00:00
|
|
|
|
|
|
|
@see @ref overview_refcount_destruct "reference-counted object destruction"
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual ~wxPalette();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-06 15:28:55 +00:00
|
|
|
Creates a palette from arrays of size @a n, one for each red, blue or
|
2008-04-06 12:52:58 +00:00
|
|
|
green component.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
The number of indices in the palette.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param red
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of red values.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param green
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of green values.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param blue
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of blue values.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the creation was successful, @false otherwise.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxPalette()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool Create(int n, const unsigned char* red,
|
|
|
|
const unsigned char* green,
|
|
|
|
const unsigned char* blue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns number of entries in palette.
|
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual int GetColoursCount() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pixel value (index into the palette) for the given RGB values.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param red
|
2008-03-09 12:33:59 +00:00
|
|
|
Red value.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param green
|
2008-03-09 12:33:59 +00:00
|
|
|
Green value.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param blue
|
2008-03-09 12:33:59 +00:00
|
|
|
Blue value.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return The nearest palette index or @c wxNOT_FOUND for unexpected errors.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetRGB()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
int GetPixel(unsigned char red, unsigned char green,
|
2008-03-09 16:24:26 +00:00
|
|
|
unsigned char blue) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns RGB values for a given palette index.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pixel
|
2008-03-09 12:33:59 +00:00
|
|
|
The palette index.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param red
|
2008-03-09 12:33:59 +00:00
|
|
|
Receives the red value.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param green
|
2008-03-09 12:33:59 +00:00
|
|
|
Receives the green value.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param blue
|
2008-03-09 12:33:59 +00:00
|
|
|
Receives the blue value.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the operation was successful.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetPixel()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-28 15:36:26 +00:00
|
|
|
bool GetRGB(int pixel, unsigned char* red, unsigned char* green,
|
|
|
|
unsigned char* blue) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if palette data is present.
|
|
|
|
*/
|
2008-10-13 11:09:56 +00:00
|
|
|
virtual bool IsOk() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-06 12:52:58 +00:00
|
|
|
Assignment operator, using @ref overview_refcount.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-04-06 12:52:58 +00:00
|
|
|
wxPalette& operator =(const wxPalette& palette);
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-06 15:28:55 +00:00
|
|
|
An empty palette.
|
2008-03-10 15:24:38 +00:00
|
|
|
*/
|
|
|
|
wxPalette wxNullPalette;
|
|
|
|
|
|
|
|
|