]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/palette.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPalette
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 A palette is a table that maps pixel values to RGB colours. It allows the
12 colours of a low-depth bitmap, for example, to be mapped to the available
13 colours in a display. The notion of palettes is becoming more and more
14 obsolete nowadays and only the MSW port is still using a native palette.
15 All other ports use generic code which is basically just an array of
18 It is likely that in the future the only use for palettes within wxWidgets
19 will be for representing colour indeces from images (such as GIF or PNG).
20 The image handlers for these formats have been modified to create a palette
21 if there is such information in the original image file (usually 256 or less
22 colour images). See wxImage for more information.
30 @see wxDC::SetPalette(), wxBitmap
32 class wxPalette
: public wxGDIObject
42 Copy constructor, uses @ref overview_refcount.
45 A reference to the palette to copy.
47 wxPalette(const wxPalette
& palette
);
50 Creates a palette from arrays of size @a n, one for each red, blue or
54 The number of indices in the palette.
56 An array of red values.
58 An array of green values.
60 An array of blue values.
63 In wxPerl this method takes as parameters
64 3 array references (they must be of the same length).
69 wxPalette(int n
, const unsigned char* red
,
70 const unsigned char* green
,
71 const unsigned char* blue
);
76 @see @ref overview_refcount_destruct "reference-counted object destruction"
81 Creates a palette from arrays of size @a n, one for each red, blue or
85 The number of indices in the palette.
87 An array of red values.
89 An array of green values.
91 An array of blue values.
93 @return @true if the creation was successful, @false otherwise.
97 bool Create(int n
, const unsigned char* red
,
98 const unsigned char* green
,
99 const unsigned char* blue
);
102 Returns number of entries in palette.
104 virtual int GetColoursCount() const;
107 Returns a pixel value (index into the palette) for the given RGB values.
116 @return The nearest palette index or @c wxNOT_FOUND for unexpected errors.
120 int GetPixel(unsigned char red
, unsigned char green
,
121 unsigned char blue
) const;
124 Returns RGB values for a given palette index.
129 Receives the red value.
131 Receives the green value.
133 Receives the blue value.
135 @return @true if the operation was successful.
138 In wxPerl this method takes only the @a pixel parameter and
139 returns a 3-element list (or the empty list upon failure).
144 bool GetRGB(int pixel
, unsigned char* red
, unsigned char* green
,
145 unsigned char* blue
) const;
148 Returns @true if palette data is present.
150 virtual bool IsOk() const;
153 Assignment operator, using @ref overview_refcount.
155 wxPalette
& operator =(const wxPalette
& palette
);
162 wxPalette wxNullPalette
;