]>
git.saurik.com Git - wxWidgets.git/blob - interface/palette.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPalette
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @ingroup group_class_gdi
14 A palette is a table that maps pixel values to RGB colours. It allows the
15 colours of a low-depth bitmap, for example, to be mapped to the available
16 colours in a display. The notion of palettes is becoming more and more
17 obsolete nowadays and only the MSW port is still using a native palette.
18 All other ports use generic code which is basically just an array of
21 It is likely that in the future the only use for palettes within wxWidgets
22 will be for representing colour indeces from images (such as GIF or PNG).
23 The image handlers for these formats have been modified to create a palette
24 if there is such information in the original image file (usually 256 or less
25 colour images). See wxImage for more information.
31 ::Objects:, ::wxNullPalette,
33 @see wxDC::SetPalette, wxBitmap
35 class wxPalette
: public wxGDIObject
40 Creates a palette from arrays of size @e n, one for each
41 red, blue or green component.
44 A pointer or reference to the palette to copy.
46 The number of indices in the palette.
48 An array of red values.
50 An array of green values.
52 An array of blue values.
57 wxPalette(const wxPalette
& palette
);
58 wxPalette(int n
, const unsigned char* red
,
59 const unsigned char* green
,
60 const unsigned char* blue
);
65 See @ref overview_refcountdestruct "reference-counted object destruction" for
71 Creates a palette from arrays of size @e n, one for each
72 red, blue or green component.
75 The number of indices in the palette.
77 An array of red values.
79 An array of green values.
81 An array of blue values.
83 @returns @true if the creation was successful, @false otherwise.
87 bool Create(int n
, const unsigned char* red
,
88 const unsigned char* green
,
89 const unsigned char* blue
);
92 Returns number of entries in palette.
94 int GetColoursCount() const;
97 Returns a pixel value (index into the palette) for the given RGB values.
106 @returns The nearest palette index or wxNOT_FOUND for unexpected errors.
110 int GetPixel(unsigned char red
, unsigned char green
,
111 unsigned char blue
) const;
114 Returns RGB values for a given palette index.
119 Receives the red value.
121 Receives the green value.
123 Receives the blue value.
125 @returns @true if the operation was successful.
129 bool GetRGB(int pixel
, const unsigned char* red
,
130 const unsigned char* green
,
131 const unsigned char* blue
) const;
134 Returns @true if palette data is present.
139 Assignment operator, using @ref overview_trefcount "reference counting".
141 wxPalette
operator =(const wxPalette
& palette
);
154 wxPalette wxNullPalette
;