Synopsis#include <gdk/gdk.h> GdkColor; GdkColormap; GdkColormap* gdk_colormap_new (GdkVisual *visual, gboolean allocate); GdkColormap* gdk_colormap_ref (GdkColormap *cmap); void gdk_colormap_unref (GdkColormap *cmap); GdkColormap* gdk_colormap_get_system (void); gint gdk_colormap_get_system_size (void); void gdk_colormap_change (GdkColormap *colormap, gint ncolors); gint gdk_colormap_alloc_colors (GdkColormap *colormap, GdkColor *colors, gint n_colors, gboolean writeable, gboolean best_match, gboolean *success); gboolean gdk_colormap_alloc_color (GdkColormap *colormap, GdkColor *color, gboolean writeable, gboolean best_match); void gdk_colormap_free_colors (GdkColormap *colormap, const GdkColor *colors, gint n_colors); void gdk_colormap_query_color (GdkColormap *colormap, gulong pixel, GdkColor *result); GdkVisual* gdk_colormap_get_visual (GdkColormap *colormap); GdkScreen* gdk_colormap_get_screen (GdkColormap *cmap); void gdk_colors_store (GdkColormap *colormap, GdkColor *colors, gint ncolors); GdkColor* gdk_color_copy (const GdkColor *color); void gdk_color_free (GdkColor *color); gint gdk_colors_alloc (GdkColormap *colormap, gboolean contiguous, gulong *planes, gint nplanes, gulong *pixels, gint npixels); void gdk_colors_free (GdkColormap *colormap, gulong *pixels, gint npixels, gulong planes); gint gdk_color_white (GdkColormap *colormap, GdkColor *color); gint gdk_color_black (GdkColormap *colormap, GdkColor *color); gboolean gdk_color_parse (const gchar *spec, GdkColor *color); gint gdk_color_alloc (GdkColormap *colormap, GdkColor *color); gint gdk_color_change (GdkColormap *colormap, GdkColor *color); gboolean gdk_color_equal (const GdkColor *colora, const GdkColor *colorb); guint gdk_color_hash (const GdkColor *colora); gchar* gdk_color_to_string (const GdkColor *color); DescriptionThese 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
In previous revisions of this interface, a number
of functions that take a GdkColormap parameter
were replaced with functions whose names began
with "gdk_colormap_". This process will probably
be extended somewhat in the future -
DetailsGdkColortypedef struct { guint32 pixel; guint16 red; guint16 green; guint16 blue; } GdkColor; The GdkColor structure is used to describe an allocated or unallocated color.
GdkColormaptypedef struct { gint size; GdkColor *colors; } GdkColormap; The colormap structure contains the following public fields.
gdk_colormap_new ()GdkColormap* gdk_colormap_new (GdkVisual *visual, gboolean allocate); Creates a new colormap for the given visual.
gdk_colormap_ref ()GdkColormap* gdk_colormap_ref (GdkColormap *cmap); Warning
Deprecated function; use
gdk_colormap_unref ()void gdk_colormap_unref (GdkColormap *cmap); Warning
Deprecated function; use
gdk_colormap_get_system ()GdkColormap* gdk_colormap_get_system (void);
Gets the system's default colormap for the default screen. (See
gdk_colormap_get_system_size ()gint gdk_colormap_get_system_size (void); Warning
Returns the size of the system's default colormap. (See the description of struct GdkColormap for an explanation of the size of a colormap.)
gdk_colormap_change ()void gdk_colormap_change (GdkColormap *colormap, gint ncolors); Warning
Changes the value of the first
gdk_colormap_alloc_colors ()gint gdk_colormap_alloc_colors (GdkColormap *colormap, GdkColor *colors, gint n_colors, gboolean writeable, gboolean best_match, gboolean *success); Allocates colors from a colormap.
gdk_colormap_alloc_color ()gboolean gdk_colormap_alloc_color (GdkColormap *colormap, GdkColor *color, gboolean writeable, gboolean best_match); Allocates a single color from a colormap.
gdk_colormap_free_colors ()void gdk_colormap_free_colors (GdkColormap *colormap, const GdkColor *colors, gint n_colors); Frees previously allocated colors.
gdk_colormap_query_color ()void gdk_colormap_query_color (GdkColormap *colormap, gulong pixel, GdkColor *result);
Locates the RGB color in This function is rarely useful; it's used for example to implement the eyedropper feature in GtkColorSelection.
gdk_colormap_get_visual ()GdkVisual* gdk_colormap_get_visual (GdkColormap *colormap); Returns the visual for which a given colormap was created.
gdk_colormap_get_screen ()GdkScreen* gdk_colormap_get_screen (GdkColormap *cmap); Gets the screen for which this colormap was created.
Since 2.2 gdk_colors_store ()void gdk_colors_store (GdkColormap *colormap, GdkColor *colors, gint ncolors); Warning
Changes the value of the first
gdk_color_copy ()GdkColor* gdk_color_copy (const GdkColor *color);
Makes a copy of a color structure. The result
must be freed using
gdk_color_free ()void gdk_color_free (GdkColor *color);
Frees a color structure created with
gdk_colors_alloc ()gint gdk_colors_alloc (GdkColormap *colormap, gboolean contiguous, gulong *planes, gint nplanes, gulong *pixels, gint npixels); Warning
Allocates colors from a colormap. This function
is obsolete. See
gdk_colors_free ()void gdk_colors_free (GdkColormap *colormap, gulong *pixels, gint npixels, gulong planes); Warning
Frees colors allocated with
gdk_color_white ()gint gdk_color_white (GdkColormap *colormap, GdkColor *color); Warning
Returns the white color for a given colormap. The resulting value has already allocated been allocated.
gdk_color_black ()gint gdk_color_black (GdkColormap *colormap, GdkColor *color); Warning
Returns the black color for a given colormap. The resulting value has already benn allocated.
gdk_color_parse ()gboolean gdk_color_parse (const gchar *spec, GdkColor *color);
Parses a textual specification of a color and fill in the
gdk_color_alloc ()gint gdk_color_alloc (GdkColormap *colormap, GdkColor *color); Warning
Allocates a single color from a colormap.
gdk_color_change ()gint gdk_color_change (GdkColormap *colormap, GdkColor *color); Warning
Changes the value of a color that has already
been allocated. If
gdk_color_equal ()gboolean gdk_color_equal (const GdkColor *colora, const GdkColor *colorb); Compares two colors.
gdk_color_hash ()guint gdk_color_hash (const GdkColor *colora); A hash function suitable for using for a hash table that stores GdkColor's.
gdk_color_to_string ()gchar* gdk_color_to_string (const GdkColor *color);
Returns a textual specification of
Since 2.12 |