Next: , Previous: Pixbufs, Up: Top


13 Colormaps and Colors

Manipulation of colors and colormaps

13.1 Overview

These functions are used to modify colormaps. A colormap is an object that contains the mapping between the color values stored in memory and the RGB values that are used to display color values. In general, colormaps only contain significant information for pseudo-color visuals, but even for other visual types, a colormap object is required in some circumstances.

There are a couple of special colormaps that can be retrieved. The system colormap (retrieved with gdk-colormap-get-system) is the default colormap of the system. If you are using GdkRGB, there is another colormap that is important - the colormap in which GdkRGB works, retrieved with gdk-rgb-get-cmap. However, when using GdkRGB, it is not generally necessary to allocate colors directly.

In previous revisions of this interface, a number of functions that take a <gdk-colormap> parameter were replaced with functions whose names began with "gdk_colormap_". This process will probably be extended somewhat in the future - gdk-color-white, gdk-color-black, and gdk-color-change will probably become aliases.

13.2 Usage

— Class: <gdk-color>

Derives from <gboxed>.

This class defines no direct slots.

— Class: <gdk-colormap>

Derives from <gobject>.

This class defines no direct slots.

— Function: gdk-color-copy (self <gdk-color>) ⇒  (ret <gdk-color>)

Makes a copy of a color structure. The result must be freed using gdk-color-free.

color
a <gdk-color>.
ret
a copy of color.
— Function: gdk-color-white (colormap <gdk-colormap>) (color <gdk-color>) ⇒  (ret int)

gdk_color_white’ is deprecated and should not be used in newly-written code.

Returns the white color for a given colormap. The resulting value has already allocated been allocated.

colormap
a <gdk-colormap>.
color
the location to store the color.
ret
#t’ if the allocation succeeded.
— Function: gdk-color-black (colormap <gdk-colormap>) (color <gdk-color>) ⇒  (ret int)

gdk_color_black’ is deprecated and should not be used in newly-written code.

Returns the black color for a given colormap. The resulting value has already benn allocated.

colormap
a <gdk-colormap>.
color
the location to store the color.
ret
#t’ if the allocation succeeded.
— Function: gdk-color-parse (spec mchars) (color <gdk-color>) ⇒  (ret bool)

Parses a textual specification of a color and fill in the , <gdk-color> structure. The color is not allocated, you must call gdk-colormap-alloc-color yourself. The text string can be in any of the forms accepted by x-parse-color; these include name for a color from rgb.txt, such as ‘DarkSlateGray’, or a hex specification such as ‘&#x0023;3050b2’ or ‘&#x0023;35b’.

spec
the string specifying the color.
color
the <gdk-color> to fill in
ret
#t’ if the parsing succeeded.
— Function: gdk-color-alloc (colormap <gdk-colormap>) (color <gdk-color>) ⇒  (ret int)

gdk_color_alloc’ is deprecated and should not be used in newly-written code. Use gdk-colormap-alloc-color instead.

Allocates a single color from a colormap.

colormap
a <gdk-colormap>.
color
The color to allocate. On return, the filled in.
ret
#t’ if the allocation succeeded.
— Function: gdk-color-change (colormap <gdk-colormap>) (color <gdk-color>) ⇒  (ret int)

gdk_color_change’ is deprecated and should not be used in newly-written code.

Changes the value of a color that has already been allocated. If colormap is not a private colormap, then the color must have been allocated using gdk-colormap-alloc-colors with the writeable set to ‘#t’.

colormap
a <gdk-colormap>.
color
a <gdk-color>, with the color to change in the field, and the new value in the remaining fields.
ret
#t’ if the color was successfully changed.