1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxPalette docs
8 %% Copyright: (c) wxWidgets
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxPalette
}}\label{wxpalette
}
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
\helpref{wxImage
}{wximage
} for more information.
27 %TODO: topic overview for wxPalette.
28 \wxheading{Derived from
}
30 \helpref{wxGDIObject
}{wxgdiobject
}\\
31 \helpref{wxObject
}{wxobject
}
33 \wxheading{Include files
}
39 \helpref{wxCore
}{librarieslist
}
41 \wxheading{Predefined objects
}
49 \helpref{wxDC::SetPalette
}{wxdcsetpalette
},
\helpref{wxBitmap
}{wxbitmap
}
51 \latexignore{\rtfignore{\wxheading{Members
}}}
53 \membersection{wxPalette::wxPalette
}\label{wxpalettector
}
55 \func{}{wxPalette
}{\void}
59 \func{}{wxPalette
}{\param{const wxPalette\&
}{ palette
}}
61 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
63 \func{}{wxPalette
}{\param{int
}{ n
},
\param{const unsigned char*
}{red
},\\
64 \param{const unsigned char*
}{green
},
\param{const unsigned char*
}{blue
}}
66 Creates a palette from arrays of size
{\it n
}, one for each
67 red, blue or green component.
69 \wxheading{Parameters
}
71 \docparam{palette
}{A pointer or reference to the palette to copy.
}
73 \docparam{n
}{The number of indices in the palette.
}
75 \docparam{red
}{An array of red values.
}
77 \docparam{green
}{An array of green values.
}
79 \docparam{blue
}{An array of blue values.
}
83 \helpref{wxPalette::Create
}{wxpalettecreate
}
85 \perlnote{In wxPerl the third constructor form takes as parameters
86 3 array references ( they must be of the same length ).
}
88 \membersection{wxPalette::
\destruct{wxPalette
}}\label{wxpalettedtor
}
90 \func{}{\destruct{wxPalette
}}{\void}
93 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
95 \membersection{wxPalette::Create
}\label{wxpalettecreate
}
97 \func{bool
}{Create
}{\param{int
}{ n
},
\param{const unsigned char*
}{red
},
\rtfsp
98 \param{const unsigned char*
}{green
},
\param{const unsigned char*
}{blue
}}
100 Creates a palette from arrays of size
{\it n
}, one for each
101 red, blue or green component.
103 \wxheading{Parameters
}
105 \docparam{n
}{The number of indices in the palette.
}
107 \docparam{red
}{An array of red values.
}
109 \docparam{green
}{An array of green values.
}
111 \docparam{blue
}{An array of blue values.
}
113 \wxheading{Return value
}
115 true if the creation was successful, false otherwise.
119 \helpref{wxPalette::wxPalette
}{wxpalettector
}
121 \membersection{wxPalette::GetColoursCount
}\label{wxpalettegetcolourscount
}
123 \constfunc{int
}{GetColoursCount
}{\void}
125 Returns number of entries in palette.
127 \membersection{wxPalette::GetPixel
}\label{wxpalettegetpixel
}
129 \constfunc{int
}{GetPixel
}{\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\rtfsp
130 \param{unsigned char
}{blue
}}
132 Returns a pixel value (index into the palette) for the given RGB values.
134 \wxheading{Parameters
}
136 \docparam{red
}{Red value.
}
138 \docparam{green
}{Green value.
}
140 \docparam{blue
}{Blue value.
}
142 \wxheading{Return value
}
144 The nearest palette index or
{\tt wxNOT
\_FOUND} for unexpected errors.
148 \helpref{wxPalette::GetRGB
}{wxpalettegetrgb
}
150 \membersection{wxPalette::GetRGB
}\label{wxpalettegetrgb
}
152 \constfunc{bool
}{GetRGB
}{\param{int
}{ pixel
},
\param{const unsigned char*
}{red
},
\param{const unsigned char*
}{green
},
\rtfsp
153 \param{const unsigned char*
}{blue
}}
155 Returns RGB values for a given palette index.
157 \wxheading{Parameters
}
159 \docparam{pixel
}{The palette index.
}
161 \docparam{red
}{Receives the red value.
}
163 \docparam{green
}{Receives the green value.
}
165 \docparam{blue
}{Receives the blue value.
}
167 \wxheading{Return value
}
169 true if the operation was successful.
173 \helpref{wxPalette::GetPixel
}{wxpalettegetpixel
}
175 \perlnote{In wxPerl this method takes only the
{\tt pixel
} parameter and
176 returns a
3-element list ( or the empty list upon failure ).
}
178 \membersection{wxPalette::IsOk
}\label{wxpaletteisok
}
180 \constfunc{bool
}{IsOk
}{\void}
182 Returns true if palette data is present.
184 \membersection{wxPalette::operator $=$
}\label{wxpaletteassignment
}
186 \func{wxPalette\&
}{operator $=$
}{\param{const wxPalette\&
}{palette
}}
188 Assignment operator, using
\helpref{reference counting
}{trefcount
}.