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
}
37 \wxheading{Predefined objects
}
45 \helpref{wxDC::SetPalette
}{wxdcsetpalette
},
\helpref{wxBitmap
}{wxbitmap
}
47 \latexignore{\rtfignore{\wxheading{Members
}}}
49 \membersection{wxPalette::wxPalette
}\label{wxpalettector
}
51 \func{}{wxPalette
}{\void}
55 \func{}{wxPalette
}{\param{const wxPalette\&
}{ palette
}}
57 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
59 \func{}{wxPalette
}{\param{int
}{ n
},
\param{const unsigned char*
}{red
},\\
60 \param{const unsigned char*
}{green
},
\param{const unsigned char*
}{blue
}}
62 Creates a palette from arrays of size
{\it n
}, one for each
63 red, blue or green component.
65 \wxheading{Parameters
}
67 \docparam{palette
}{A pointer or reference to the palette to copy.
}
69 \docparam{n
}{The number of indices in the palette.
}
71 \docparam{red
}{An array of red values.
}
73 \docparam{green
}{An array of green values.
}
75 \docparam{blue
}{An array of blue values.
}
79 \helpref{wxPalette::Create
}{wxpalettecreate
}
81 \perlnote{In wxPerl the third constructor form takes as parameters
82 3 array references ( they must be of the same length ).
}
84 \membersection{wxPalette::
\destruct{wxPalette
}}\label{wxpalettedtor
}
86 \func{}{\destruct{wxPalette
}}{\void}
89 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
91 \membersection{wxPalette::Create
}\label{wxpalettecreate
}
93 \func{bool
}{Create
}{\param{int
}{ n
},
\param{const unsigned char*
}{red
},
\rtfsp
94 \param{const unsigned char*
}{green
},
\param{const unsigned char*
}{blue
}}
96 Creates a palette from arrays of size
{\it n
}, one for each
97 red, blue or green component.
99 \wxheading{Parameters
}
101 \docparam{n
}{The number of indices in the palette.
}
103 \docparam{red
}{An array of red values.
}
105 \docparam{green
}{An array of green values.
}
107 \docparam{blue
}{An array of blue values.
}
109 \wxheading{Return value
}
111 true if the creation was successful, false otherwise.
115 \helpref{wxPalette::wxPalette
}{wxpalettector
}
117 \membersection{wxPalette::GetColoursCount
}\label{wxpalettegetcolourscount
}
119 \constfunc{int
}{GetColoursCount
}{\void}
121 Returns number of entries in palette.
123 \membersection{wxPalette::GetPixel
}\label{wxpalettegetpixel
}
125 \constfunc{int
}{GetPixel
}{\param{unsigned char
}{red
},
\param{unsigned char
}{green
},
\rtfsp
126 \param{unsigned char
}{blue
}}
128 Returns a pixel value (index into the palette) for the given RGB values.
130 \wxheading{Parameters
}
132 \docparam{red
}{Red value.
}
134 \docparam{green
}{Green value.
}
136 \docparam{blue
}{Blue value.
}
138 \wxheading{Return value
}
140 The nearest palette index or
{\tt wxNOT
\_FOUND} for unexpected errors.
144 \helpref{wxPalette::GetRGB
}{wxpalettegetrgb
}
146 \membersection{wxPalette::GetRGB
}\label{wxpalettegetrgb
}
148 \constfunc{bool
}{GetRGB
}{\param{int
}{ pixel
},
\param{const unsigned char*
}{red
},
\param{const unsigned char*
}{green
},
\rtfsp
149 \param{const unsigned char*
}{blue
}}
151 Returns RGB values for a given palette index.
153 \wxheading{Parameters
}
155 \docparam{pixel
}{The palette index.
}
157 \docparam{red
}{Receives the red value.
}
159 \docparam{green
}{Receives the green value.
}
161 \docparam{blue
}{Receives the blue value.
}
163 \wxheading{Return value
}
165 true if the operation was successful.
169 \helpref{wxPalette::GetPixel
}{wxpalettegetpixel
}
171 \perlnote{In wxPerl this method takes only the
{\tt pixel
} parameter and
172 returns a
3-element list ( or the empty list upon failure ).
}
174 \membersection{wxPalette::IsOk
}\label{wxpaletteisok
}
176 \constfunc{bool
}{IsOk
}{\void}
178 Returns true if palette data is present.
180 \membersection{wxPalette::operator $=$
}\label{wxpaletteassignment
}
182 \func{wxPalette\&
}{operator $=$
}{\param{const wxPalette\&
}{palette
}}
184 Assignment operator, using
\helpref{reference counting
}{trefcount
}.