1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 manipulation of colors and colormaps.
7 <!-- ##### SECTION Long_Description ##### -->
9 These functions are used to modify colormaps.
10 A colormap is an object that contains the mapping
11 between the color values stored in memory and
12 the RGB values that are used to display color
13 values. In general, colormaps only contain
14 significant information for pseudo-color visuals,
15 but even for other visual types, a colormap object
16 is required in some circumstances.
20 There are a couple of special colormaps that can
21 be retrieved. The system colormap (retrieved
22 with gdk_colormap_get_system()) is the default
23 colormap of the system. If you are using GdkRGB,
24 there is another colormap that is important - the
25 colormap in which GdkRGB works, retrieved with
26 gdk_rgb_get_cmap(). However, when using GdkRGB,
27 it is not generally necessary to allocate colors
32 In previous revisions of this interface, a number
33 of functions that take a #GdkColormap parameter
34 were replaced with functions whose names began
35 with "gdk_colormap_". This process will probably
36 be extended somewhat in the future -
37 gdk_color_white(), gdk_color_black(), and
38 gdk_color_change() will probably become aliases.
41 <!-- ##### SECTION See_Also ##### -->
46 <!-- ##### STRUCT GdkColor ##### -->
48 The #GdkColor structure is used to describe an
49 allocated or unallocated color.
51 <informaltable pgwide=1 frame="none" role="struct">
52 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
56 <entry><structfield>pixel</structfield></entry>
57 <entry>For allocated colors, the value used to
58 draw this color on the screen.</entry>
62 <entry><structfield>red</structfield></entry>
63 <entry>The red component of the color. This is
64 a value between 0 and 65535, with 65535 indicating
65 full intensitiy.</entry>
69 <entry><structfield>green</structfield></entry>
70 <entry>the blue component of the color.</entry>
74 <entry><structfield>blue</structfield></entry>
75 <entry>the green component of the color..</entry>
78 </tbody></tgroup></informaltable>
86 <!-- ##### STRUCT GdkColormap ##### -->
88 The colormap structure contains the following public
91 <informaltable pgwide=1 frame="none" role="struct">
92 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
96 <entry><structfield>size</structfield></entry>
97 <entry>For pseudo-color colormaps, the number of colors
98 in the colormap..</entry>
102 <entry><structfield>colors</structfield></entry>
103 <entry>An array containing the current values in the
104 colormap. This can be used to map from pixel values
105 back to RGB values. This is only meaningful for
106 pseudo-color colormaps.</entry>
109 </tbody></tgroup></informaltable>
116 <!-- ##### FUNCTION gdk_colormap_new ##### -->
118 Create a new colormap for the given visual.
121 @visual: a #GdkVisual.
122 @allocate: if %TRUE, the newly created colormap will be
123 a private colormap, and all colors in it will be
124 allocated for the applications use.
125 @Returns: the new #GdkColormap.
128 <!-- ##### FUNCTION gdk_colormap_ref ##### -->
130 Increase the reference count of a colormap.
133 @cmap: a #GdkColormap.
137 <!-- ##### FUNCTION gdk_colormap_unref ##### -->
139 Decrease the reference count of a colormap. If the
140 resulting reference count is zero, destroys the colormap.
143 @cmap: a #GdkColormap.
146 <!-- ##### FUNCTION gdk_colormap_get_system ##### -->
148 Returns the system's default colormap.
151 @Returns: the default colormap.
154 <!-- ##### FUNCTION gdk_colormap_get_system_size ##### -->
156 Returns the size of the system's default colormap.
157 (See the description of struct #GdkColormap for an
158 explanation of the size of a colormap.)
161 @Returns: the size of the system's default colormap.
164 <!-- ##### FUNCTION gdk_colormap_change ##### -->
166 Change the value of the first @ncolors in a private colormap
167 to match the values in the <structfield>colors</structfield>
168 array in the color map. This function is obsolete and
169 should not be used. See gdk_color_change().
172 @colormap: a #GdkColormap.
173 @ncolors: the number of colors to change.
176 <!-- ##### FUNCTION gdk_colormap_alloc_colors ##### -->
178 Allocates colors from a colormap.
181 @colormap: a #GdkColormap.
182 @colors: The color values to allocate. On return, the pixel
183 values for allocated colors will be filled in.
184 @ncolors: The number of colors in @colors.
185 @writeable: If %TRUE, the colors are allocated writeable
186 (their values can later be changed using gdk_color_change()).
187 Writeable colors cannot be shared between applications.
188 @best_match: If %TRUE, GDK will attempt to do matching against
189 existing colors if the colors cannot be allocated as
191 @success: An array of length @ncolors. On return, this
192 indicates whether the corresponding color in @colors was
193 sucessfully allocated or not.
194 @Returns: The number of colors that were not sucessfully
198 <!-- ##### FUNCTION gdk_colormap_alloc_color ##### -->
200 Allocate a single color from a colormap.
203 @colormap: a #GdkColormap.
204 @color: the color to allocate. On return the
205 <structfield>pixel</structfield> field will be
206 filled in if allocation succeeds.
207 @writeable: If %TRUE, the color is allocated writeable
208 (their values can later be changed using gdk_color_change()).
209 Writeable colors cannot be shared between applications.
210 @best_match: If %TRUE, GDK will attempt to do matching against
211 existing colors if the color cannot be allocated as
213 @Returns: %TRUE if the allocation succeeded.
216 <!-- ##### FUNCTION gdk_colormap_free_colors ##### -->
218 Free previously allocated colors.
221 @colormap: a #GdkColormap.
222 @colors: the colors to free.
223 @ncolors: the number of colors in @colors.
226 <!-- ##### FUNCTION gdk_colormap_get_visual ##### -->
228 Return the visual for which a given colormap was created.
231 @colormap: a #GdkColormap.
232 @Returns: the visual of the colormap.
235 <!-- ##### FUNCTION gdk_colors_store ##### -->
237 Change the value of the first @ncolors colors in
238 a private colormap. This function is obsolete and
239 should not be used. See gdk_color_change().
242 @colormap: a #GdkColormap.
243 @colors: the new color values.
244 @ncolors: the number of colors to change.
247 <!-- ##### FUNCTION gdk_color_copy ##### -->
249 Make a copy of a color structure. The result
250 must be freed using gdk_color_free().
254 @Returns: a copy of @color.
257 <!-- ##### FUNCTION gdk_color_free ##### -->
259 Free a color structure created with
266 <!-- ##### FUNCTION gdk_colors_alloc ##### -->
268 Allocate colors from a colormap. This function
269 is obsolete. See gdk_colormap_alloc_colors().
270 For full documentation of the fields, see
271 the Xlib documentation for XAllocColorCells.
274 @colormap: a #GdkColormap.
275 @contiguous: if %TRUE, the colors should be allocated
276 in contiguous color cells.
277 @planes: an array in which to store the plane masks.
278 @nplanes: the number of planes to allocate. (Or zero,
279 to indicate that the color allocation should not be
281 @pixels: an array into which to store allocated pixel
283 @npixels: the number of pixels in each plane to allocate.
287 <!-- ##### FUNCTION gdk_colors_free ##### -->
289 Free colors allocated with gdk_colors_alloc(). This
290 function is obsolete. See gdk_colormap_free_colors().
293 @colormap: a #GdkColormap.
294 @pixels: the pixel values of the colors to free.
295 @npixels: the number of values in @pixels.
296 @planes: the plane masks for all planes to free, OR'd
300 <!-- ##### FUNCTION gdk_color_white ##### -->
302 Return the white color for a given colormap. The resulting
303 value has already allocated been allocated.
306 @colormap: a #GdkColormap.
307 @color: the location to store the color.
308 @Returns: %TRUE if the allocation succeeded.
311 <!-- ##### FUNCTION gdk_color_black ##### -->
313 Return the black color for a given colormap. The resulting
314 value has already benn allocated.
317 @colormap: a #GdkColormap.
318 @color: the location to store the color.
319 @Returns: %TRUE if the allocation succeeded.
322 <!-- ##### FUNCTION gdk_color_parse ##### -->
324 Parse a textual specification of a color and fill in
325 the <structfield>red</structfield>,
326 <structfield>green</structfield>, and
327 <structfield>blue</structfield> fields of a
328 #GdkColor structure. The color is <emphasis>not</emphasis>
329 allocated, you must call gdk_colormap_alloc_color() yourself.
330 The text string can be in any of the forms accepted
331 by <function>XParseColor</function>; these include
332 name for a color from <filename>rgb.txt</filename>, such as
333 <literal>DarkSlateGray</literal>, or a hex specification
334 such as <literal>305050</literal>.
337 @spec: the string specifying the color.
338 @color: the #GdkColor to fill in
342 <!-- ##### FUNCTION gdk_color_alloc ##### -->
344 Allocate a single color from a colormap.
345 This function is obsolete. See gdk_colormap_alloc_color().
348 @colormap: a #GdkColormap.
349 @color: The color to allocate. On return, the
350 <structfield>pixel</structfield> field will be
352 @Returns: %TRUE if the allocation succeeded.
355 <!-- ##### FUNCTION gdk_color_change ##### -->
357 Change the value of a color that has already
358 been allocated. If @colormap is not a private
359 colormap, then the color must have been allocated
360 using gdk_colormap_alloc_colors() with the
361 @writeable set to %TRUE.
364 @colormap: a #GdkColormap.
365 @color: a #GdkColor, with the color to change
366 in the <structfield>pixel</structfield> field,
367 and the new value in the remaining fields.
371 <!-- ##### FUNCTION gdk_color_equal ##### -->
376 @colora: a #GdkColor.
377 @colorb: another #GdkColor.
378 @Returns: %TRUE if the two colors compare equal
381 <!-- ##### FUNCTION gdk_color_hash ##### -->
383 A hash function suitable for using for a hash
384 table that stores #GdkColor's.
387 @colora: a #GdkColor.
388 @Returns: The hash function appled to @colora
389 <!-- # Unused Parameters # -->