<refentry id="gdk-Colormaps-and-Colors">
<refmeta>
<refentrytitle>Colormaps and Colors</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Colormaps and Colors</refname><refpurpose>manipulation of colors and colormaps.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>

#include &lt;gdk/gdk.h&gt;


struct      <link linkend="GdkColor">GdkColor</link>;
struct      <link linkend="GdkColormap">GdkColormap</link>;
<link linkend="GdkColormap">GdkColormap</link>* <link linkend="gdk-colormap-new">gdk_colormap_new</link>               (<link linkend="GdkVisual">GdkVisual</link> *visual,
                                             <link linkend="gboolean">gboolean</link> allocate);
<link linkend="GdkColormap">GdkColormap</link>* <link linkend="gdk-colormap-ref">gdk_colormap_ref</link>               (<link linkend="GdkColormap">GdkColormap</link> *cmap);
void        <link linkend="gdk-colormap-unref">gdk_colormap_unref</link>              (<link linkend="GdkColormap">GdkColormap</link> *cmap);
<link linkend="GdkColormap">GdkColormap</link>* <link linkend="gdk-colormap-get-system">gdk_colormap_get_system</link>        (void);
<link linkend="gint">gint</link>        <link linkend="gdk-colormap-get-system-size">gdk_colormap_get_system_size</link>    (void);
void        <link linkend="gdk-colormap-change">gdk_colormap_change</link>             (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gint">gint</link> ncolors);
<link linkend="gint">gint</link>        <link linkend="gdk-colormap-alloc-colors">gdk_colormap_alloc_colors</link>       (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors,
                                             <link linkend="gboolean">gboolean</link> writeable,
                                             <link linkend="gboolean">gboolean</link> best_match,
                                             <link linkend="gboolean">gboolean</link> *success);
<link linkend="gboolean">gboolean</link>    <link linkend="gdk-colormap-alloc-color">gdk_colormap_alloc_color</link>        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color,
                                             <link linkend="gboolean">gboolean</link> writeable,
                                             <link linkend="gboolean">gboolean</link> best_match);
void        <link linkend="gdk-colormap-free-colors">gdk_colormap_free_colors</link>        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors);
void        <link linkend="gdk-colormap-query-color">gdk_colormap_query_color</link>        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gulong">gulong</link> pixel,
                                             <link linkend="GdkColor">GdkColor</link> *result);
<link linkend="GdkVisual">GdkVisual</link>*  <link linkend="gdk-colormap-get-visual">gdk_colormap_get_visual</link>         (<link linkend="GdkColormap">GdkColormap</link> *colormap);
void        <link linkend="gdk-colors-store">gdk_colors_store</link>                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors);
<link linkend="GdkColor">GdkColor</link>*   <link linkend="gdk-color-copy">gdk_color_copy</link>                  (const <link linkend="GdkColor">GdkColor</link> *color);
void        <link linkend="gdk-color-free">gdk_color_free</link>                  (<link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gint">gint</link>        <link linkend="gdk-colors-alloc">gdk_colors_alloc</link>                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gboolean">gboolean</link> contiguous,
                                             <link linkend="gulong">gulong</link> *planes,
                                             <link linkend="gint">gint</link> nplanes,
                                             <link linkend="gulong">gulong</link> *pixels,
                                             <link linkend="gint">gint</link> npixels);
void        <link linkend="gdk-colors-free">gdk_colors_free</link>                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gulong">gulong</link> *pixels,
                                             <link linkend="gint">gint</link> npixels,
                                             <link linkend="gulong">gulong</link> planes);
<link linkend="gint">gint</link>        <link linkend="gdk-color-white">gdk_color_white</link>                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gint">gint</link>        <link linkend="gdk-color-black">gdk_color_black</link>                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gint">gint</link>        <link linkend="gdk-color-parse">gdk_color_parse</link>                 (const <link linkend="gchar">gchar</link> *spec,
                                             <link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gint">gint</link>        <link linkend="gdk-color-alloc">gdk_color_alloc</link>                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gint">gint</link>        <link linkend="gdk-color-change">gdk_color_change</link>                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);
<link linkend="gboolean">gboolean</link>    <link linkend="gdk-color-equal">gdk_color_equal</link>                 (const <link linkend="GdkColor">GdkColor</link> *colora,
                                             const <link linkend="GdkColor">GdkColor</link> *colorb);
<link linkend="guint">guint</link>       <link linkend="gdk-color-hash">gdk_color_hash</link>                  (const <link linkend="GdkColor">GdkColor</link> *colora);


</synopsis>
</refsynopsisdiv>





<refsect1>
<title>Description</title>
<para>
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.
</para>

<para>
There are a couple of special colormaps that can
be retrieved. The system colormap (retrieved 
with <link linkend="gdk-colormap-get-system">gdk_colormap_get_system</link>()) 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
<link linkend="gdk-rgb-get-cmap">gdk_rgb_get_cmap</link>(). However, when using GdkRGB, 
it is not generally necessary to allocate colors
directly.
</para>

<para>
In previous revisions of this interface, a number
of functions that take a <link linkend="GdkColormap">GdkColormap</link> parameter
were replaced with functions whose names began
with "gdk_colormap_". This process will probably
be extended somewhat in the future - 
<link linkend="gdk-color-white">gdk_color_white</link>(), <link linkend="gdk-color-black">gdk_color_black</link>(), and 
<link linkend="gdk-color-change">gdk_color_change</link>() will probably become aliases.
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="GdkColor">struct GdkColor</title>
<programlisting>struct GdkColor
{
  guint32 pixel;
  guint16 red;
  guint16 green;
  guint16 blue;
};
</programlisting>
<para>
The <link linkend="GdkColor">GdkColor</link> structure is used to describe an 
allocated or unallocated color.
</para><informaltable pgwide="1" frame="none" role="struct">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row>
<entry><link linkend="guint32">guint32</link> <structfield>pixel</structfield></entry>
<entry>For allocated colors, the value used to
  draw this color on the screen.
</entry>
</row>
<row>
<entry><link linkend="guint16">guint16</link> <structfield>red</structfield></entry>
<entry>The red component of the color. This is
  a value between 0 and 65535, with 65535 indicating
  full intensitiy.
</entry>
</row>
<row>
<entry><link linkend="guint16">guint16</link> <structfield>green</structfield></entry>
<entry>The blue component of the color.
</entry>
</row>
<row>
<entry><link linkend="guint16">guint16</link> <structfield>blue</structfield></entry>
<entry>The green component of the color.

</entry>
</row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="GdkColormap">struct GdkColormap</title>
<programlisting>struct GdkColormap
{
  GObject parent_instance;

  /*&lt; public &gt;*/
  gint      size;
  GdkColor *colors;

  /*&lt; private &gt;*/
  GdkVisual *visual;
  
  gpointer windowing_data;
};
</programlisting>
<para>
The colormap structure contains the following public fields.
</para><informaltable pgwide="1" frame="none" role="struct">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row>
<entry><link linkend="GObject">GObject</link> <structfield>parent_instance</structfield></entry>
<entry>
</entry>
</row>
<row>
<entry><link linkend="gint">gint</link> <structfield>size</structfield></entry>
<entry>For pseudo-color colormaps, the number of colors
  in the colormap.
</entry>
</row>
<row>
<entry><link linkend="GdkColor">GdkColor</link> *<structfield>colors</structfield></entry>
<entry>An array containing the current values in the
  colormap. This can be used to map from pixel values
  back to RGB values. This is only meaningful for
  pseudo-color colormaps.

</entry>
</row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-new">gdk_colormap_new ()</title>
<programlisting><link linkend="GdkColormap">GdkColormap</link>* gdk_colormap_new               (<link linkend="GdkVisual">GdkVisual</link> *visual,
                                             <link linkend="gboolean">gboolean</link> allocate);</programlisting>
<para>
Creates a new colormap for the given visual.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>visual</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkVisual">GdkVisual</link>.
</entry></row>
<row><entry align="right"><parameter>allocate</parameter>&nbsp;:</entry>
<entry>if <literal>TRUE</literal>, the newly created colormap will be
  a private colormap, and all colors in it will be
  allocated for the applications use.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the new <link linkend="GdkColormap">GdkColormap</link>.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-ref">gdk_colormap_ref ()</title>
<programlisting><link linkend="GdkColormap">GdkColormap</link>* gdk_colormap_ref               (<link linkend="GdkColormap">GdkColormap</link> *cmap);</programlisting>
<warning>
<para>
<literal>gdk_colormap_ref</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Deprecated function; use <link linkend="g-object-ref">g_object_ref</link>() instead.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>cmap</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdkColormap">GdkColormap</link>
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the colormap
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-unref">gdk_colormap_unref ()</title>
<programlisting>void        gdk_colormap_unref              (<link linkend="GdkColormap">GdkColormap</link> *cmap);</programlisting>
<warning>
<para>
<literal>gdk_colormap_unref</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Deprecated function; use <link linkend="g-object-ref">g_object_ref</link>() instead.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>cmap</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdkColormap">GdkColormap</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-get-system">gdk_colormap_get_system ()</title>
<programlisting><link linkend="GdkColormap">GdkColormap</link>* gdk_colormap_get_system        (void);</programlisting>
<para>
Returns the system's default colormap.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the default colormap.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-get-system-size">gdk_colormap_get_system_size ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_colormap_get_system_size    (void);</programlisting>
<warning>
<para>
<literal>gdk_colormap_get_system_size</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Returns the size of the system's default colormap.
(See the description of struct <link linkend="GdkColormap">GdkColormap</link> for an
explanation of the size of a colormap.)
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the size of the system's default colormap.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-change">gdk_colormap_change ()</title>
<programlisting>void        gdk_colormap_change             (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gint">gint</link> ncolors);</programlisting>
<warning>
<para>
<literal>gdk_colormap_change</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Changes the value of the first <parameter>ncolors</parameter> in a private colormap
to match the values in the <structfield>colors</structfield>
array in the color map. This function is obsolete and
should not be used. See <link linkend="gdk-color-change">gdk_color_change</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>ncolors</parameter>&nbsp;:</entry>
<entry>the number of colors to change.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-alloc-colors">gdk_colormap_alloc_colors ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_colormap_alloc_colors       (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors,
                                             <link linkend="gboolean">gboolean</link> writeable,
                                             <link linkend="gboolean">gboolean</link> best_match,
                                             <link linkend="gboolean">gboolean</link> *success);</programlisting>
<para>
Allocates colors from a colormap.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>colors</parameter>&nbsp;:</entry>
<entry>The color values to allocate. On return, the pixel
 values for allocated colors will be filled in.
</entry></row>
<row><entry align="right"><parameter>ncolors</parameter>&nbsp;:</entry>
<entry>The number of colors in <parameter>colors</parameter>.
</entry></row>
<row><entry align="right"><parameter>writeable</parameter>&nbsp;:</entry>
<entry>If <literal>TRUE</literal>, the colors are allocated writeable
 (their values can later be changed using <link linkend="gdk-color-change">gdk_color_change</link>()).
 Writeable colors cannot be shared between applications.
</entry></row>
<row><entry align="right"><parameter>best_match</parameter>&nbsp;:</entry>
<entry>If <literal>TRUE</literal>, GDK will attempt to do matching against
 existing colors if the colors cannot be allocated as
 requested.
</entry></row>
<row><entry align="right"><parameter>success</parameter>&nbsp;:</entry>
<entry>An array of length <parameter>ncolors</parameter>. On return, this
 indicates whether the corresponding color in <parameter>colors</parameter> was
 sucessfully allocated or not.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>The number of colors that were not sucessfully 
 allocated.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-alloc-color">gdk_colormap_alloc_color ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gdk_colormap_alloc_color        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color,
                                             <link linkend="gboolean">gboolean</link> writeable,
                                             <link linkend="gboolean">gboolean</link> best_match);</programlisting>
<para>
Allocates a single color from a colormap.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>the color to allocate. On return the
<structfield>pixel</structfield> field will be
filled in if allocation succeeds.
</entry></row>
<row><entry align="right"><parameter>writeable</parameter>&nbsp;:</entry>
<entry>If <literal>TRUE</literal>, the color is allocated writeable
 (their values can later be changed using <link linkend="gdk-color-change">gdk_color_change</link>()).
 Writeable colors cannot be shared between applications.
</entry></row>
<row><entry align="right"><parameter>best_match</parameter>&nbsp;:</entry>
<entry>If <literal>TRUE</literal>, GDK will attempt to do matching against
 existing colors if the color cannot be allocated as
 requested.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the allocation succeeded.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-free-colors">gdk_colormap_free_colors ()</title>
<programlisting>void        gdk_colormap_free_colors        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors);</programlisting>
<para>
Frees previously allocated colors.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>colors</parameter>&nbsp;:</entry>
<entry>the colors to free.
</entry></row>
<row><entry align="right"><parameter>ncolors</parameter>&nbsp;:</entry>
<entry>the number of colors in <parameter>colors</parameter>.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-query-color">gdk_colormap_query_color ()</title>
<programlisting>void        gdk_colormap_query_color        (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gulong">gulong</link> pixel,
                                             <link linkend="GdkColor">GdkColor</link> *result);</programlisting>
<para>
Locates the RGB color in <parameter>colormap</parameter> corresponding to the given
hardware pixel <parameter>pixel</parameter>. <parameter>pixel</parameter> must be a valid pixel in the
colormap; it's a programmer error to call this function with a
pixel which is not in the colormap. Hardware pixels are normally
obtained from <link linkend="gdk-colormap-alloc-colors">gdk_colormap_alloc_colors</link>(), or from a <link linkend="GdkImage">GdkImage</link>. (A
<link linkend="GdkImage">GdkImage</link> contains image data in hardware format, a <link linkend="GdkPixbuf">GdkPixbuf</link>
contains image data in a canonical 24-bit RGB format.)
</para>
<para>
This function is rarely useful, it's used for example to
implement the eyedropper feature in <link linkend="GtkColorSelection">GtkColorSelection</link>.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry> a <link linkend="GdkColormap">GdkColormap</link>
</entry></row>
<row><entry align="right"><parameter>pixel</parameter>&nbsp;:</entry>
<entry> pixel value in hardware display format
</entry></row>
<row><entry align="right"><parameter>result</parameter>&nbsp;:</entry>
<entry> <link linkend="GdkColor">GdkColor</link> with red, green, blue fields initialized
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colormap-get-visual">gdk_colormap_get_visual ()</title>
<programlisting><link linkend="GdkVisual">GdkVisual</link>*  gdk_colormap_get_visual         (<link linkend="GdkColormap">GdkColormap</link> *colormap);</programlisting>
<para>
Returns the visual for which a given colormap was created.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the visual of the colormap.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colors-store">gdk_colors_store ()</title>
<programlisting>void        gdk_colors_store                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *colors,
                                             <link linkend="gint">gint</link> ncolors);</programlisting>
<warning>
<para>
<literal>gdk_colors_store</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Changes the value of the first <parameter>ncolors</parameter> colors in
a private colormap. This function is obsolete and
should not be used. See <link linkend="gdk-color-change">gdk_color_change</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>colors</parameter>&nbsp;:</entry>
<entry>the new color values.
</entry></row>
<row><entry align="right"><parameter>ncolors</parameter>&nbsp;:</entry>
<entry>the number of colors to change.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-copy">gdk_color_copy ()</title>
<programlisting><link linkend="GdkColor">GdkColor</link>*   gdk_color_copy                  (const <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<para>
Makes a copy of a color structure. The result
must be freed using <link linkend="gdk-color-free">gdk_color_free</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColor">GdkColor</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a copy of <parameter>color</parameter>.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-free">gdk_color_free ()</title>
<programlisting>void        gdk_color_free                  (<link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<para>
Frees a color structure created with 
<link linkend="gdk-color-copy">gdk_color_copy</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColor">GdkColor</link>.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colors-alloc">gdk_colors_alloc ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_colors_alloc                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gboolean">gboolean</link> contiguous,
                                             <link linkend="gulong">gulong</link> *planes,
                                             <link linkend="gint">gint</link> nplanes,
                                             <link linkend="gulong">gulong</link> *pixels,
                                             <link linkend="gint">gint</link> npixels);</programlisting>
<warning>
<para>
<literal>gdk_colors_alloc</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Allocates colors from a colormap. This function
is obsolete. See <link linkend="gdk-colormap-alloc-colors">gdk_colormap_alloc_colors</link>().
For full documentation of the fields, see 
the Xlib documentation for <function><link linkend="XAllocColorCells">XAllocColorCells</link>()</function>.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>contiguous</parameter>&nbsp;:</entry>
<entry>if <literal>TRUE</literal>, the colors should be allocated
 in contiguous color cells.
</entry></row>
<row><entry align="right"><parameter>planes</parameter>&nbsp;:</entry>
<entry>an array in which to store the plane masks.
</entry></row>
<row><entry align="right"><parameter>nplanes</parameter>&nbsp;:</entry>
<entry>the number of planes to allocate. (Or zero,
 to indicate that the color allocation should not be
 planar.)
</entry></row>
<row><entry align="right"><parameter>pixels</parameter>&nbsp;:</entry>
<entry>an array into which to store allocated pixel
 values.
</entry></row>
<row><entry align="right"><parameter>npixels</parameter>&nbsp;:</entry>
<entry>the number of pixels in each plane to allocate.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-colors-free">gdk_colors_free ()</title>
<programlisting>void        gdk_colors_free                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="gulong">gulong</link> *pixels,
                                             <link linkend="gint">gint</link> npixels,
                                             <link linkend="gulong">gulong</link> planes);</programlisting>
<warning>
<para>
<literal>gdk_colors_free</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Frees colors allocated with <link linkend="gdk-colors-alloc">gdk_colors_alloc</link>(). This
function is obsolete. See <link linkend="gdk-colormap-free-colors">gdk_colormap_free_colors</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>pixels</parameter>&nbsp;:</entry>
<entry>the pixel values of the colors to free.
</entry></row>
<row><entry align="right"><parameter>npixels</parameter>&nbsp;:</entry>
<entry>the number of values in <parameter>pixels</parameter>.
</entry></row>
<row><entry align="right"><parameter>planes</parameter>&nbsp;:</entry>
<entry>the plane masks for all planes to free, OR'd
 together.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-white">gdk_color_white ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_color_white                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<warning>
<para>
<literal>gdk_color_white</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Returns the white color for a given colormap. The resulting
value has already allocated been allocated. 
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>the location to store the color.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the allocation succeeded.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-black">gdk_color_black ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_color_black                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<warning>
<para>
<literal>gdk_color_black</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Returns the black color for a given colormap. The resulting
value has already benn allocated. 
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>the location to store the color.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the allocation succeeded.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-parse">gdk_color_parse ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_color_parse                 (const <link linkend="gchar">gchar</link> *spec,
                                             <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<para>
Parses a textual specification of a color and fill in
the <structfield>red</structfield>,
<structfield>green</structfield>, and 
<structfield>blue</structfield> fields of a 
<link linkend="GdkColor">GdkColor</link> structure. The color is <emphasis>not</emphasis> 
allocated, you must call <link linkend="gdk-colormap-alloc-color">gdk_colormap_alloc_color</link>() yourself.
The text string can be in any of the forms accepted
by <function>XParseColor</function>; these include
name for a color from <filename>rgb.txt</filename>, such as
<literal>DarkSlateGray</literal>, or a hex specification
such as <literal>305050</literal>.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>spec</parameter>&nbsp;:</entry>
<entry>the string specifying the color.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>the <link linkend="GdkColor">GdkColor</link> to fill in
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-alloc">gdk_color_alloc ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_color_alloc                 (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<warning>
<para>
<literal>gdk_color_alloc</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Allocates a single color from a colormap.
This function is obsolete. See <link linkend="gdk-colormap-alloc-color">gdk_colormap_alloc_color</link>().
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>The color to allocate. On return, the 
<structfield>pixel</structfield> field will be
filled in.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the allocation succeeded.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-change">gdk_color_change ()</title>
<programlisting><link linkend="gint">gint</link>        gdk_color_change                (<link linkend="GdkColormap">GdkColormap</link> *colormap,
                                             <link linkend="GdkColor">GdkColor</link> *color);</programlisting>
<warning>
<para>
<literal>gdk_color_change</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Changes the value of a color that has already
been allocated. If <parameter>colormap</parameter> is not a private
colormap, then the color must have been allocated
using <link linkend="gdk-colormap-alloc-colors">gdk_colormap_alloc_colors</link>() with the 
<parameter>writeable</parameter> set to <literal>TRUE</literal>.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colormap</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColormap">GdkColormap</link>.
</entry></row>
<row><entry align="right"><parameter>color</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColor">GdkColor</link>, with the color to change
in the <structfield>pixel</structfield> field,
and the new value in the remaining fields.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-equal">gdk_color_equal ()</title>
<programlisting><link linkend="gboolean">gboolean</link>    gdk_color_equal                 (const <link linkend="GdkColor">GdkColor</link> *colora,
                                             const <link linkend="GdkColor">GdkColor</link> *colorb);</programlisting>
<para>
Compares two colors. 
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colora</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColor">GdkColor</link>.
</entry></row>
<row><entry align="right"><parameter>colorb</parameter>&nbsp;:</entry>
<entry>another <link linkend="GdkColor">GdkColor</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the two colors compare equal


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gdk-color-hash">gdk_color_hash ()</title>
<programlisting><link linkend="guint">guint</link>       gdk_color_hash                  (const <link linkend="GdkColor">GdkColor</link> *colora);</programlisting>
<para>
A hash function suitable for using for a hash
table that stores <link linkend="GdkColor">GdkColor</link>'s.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>colora</parameter>&nbsp;:</entry>
<entry>a <link linkend="GdkColor">GdkColor</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>The hash function appled to <parameter>colora</parameter>


</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>




</refentry>
