?? gdk-colormaps-and-colors.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Colormaps and Colors</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GDK Reference Manual"><link rel="up" href="reference.html" title="API Reference"><link rel="prev" href="gdk-Pixbufs.html" title="Pixbufs"><link rel="next" href="gdk-Visuals.html" title="Visuals"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="reference" href="reference.html" title="API Reference"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gdk-Pixbufs.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GDK Reference Manual</th><td><a accesskey="n" href="gdk-Visuals.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3145331" class="shortcut">Top</a>  |  <a href="#id3146148" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="gdk-Colormaps-and-Colors"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3145331"></a><span class="refentrytitle">Colormaps and Colors</span></h2><p>Colormaps and Colors — Manipulation of colors and colormaps</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include <gdk/gdk.h> <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a>; <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a>;<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-new">gdk_colormap_new</a> (<a class="link" href="gdk-Visuals.html#GdkVisual">GdkVisual</a> *visual, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> allocate);<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-ref">gdk_colormap_ref</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *cmap);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-unref">gdk_colormap_unref</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *cmap);<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-get-system">gdk_colormap_get_system</a> (void);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-get-system-size">gdk_colormap_get_system_size</a> (void);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-change">gdk_colormap_change</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> ncolors);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-alloc-colors">gdk_colormap_alloc_colors</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colors, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> ncolors, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> writeable, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> best_match, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> *success);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-alloc-color">gdk_colormap_alloc_color</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> writeable, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> best_match);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-free-colors">gdk_colormap_free_colors</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colors, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> ncolors);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-query-color">gdk_colormap_query_color</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gulong">gulong</a> pixel, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *result);<a class="link" href="gdk-Visuals.html#GdkVisual">GdkVisual</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-get-visual">gdk_colormap_get_visual</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap);<a class="link" href="GdkScreen.html" title="GdkScreen">GdkScreen</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-get-screen">gdk_colormap_get_screen</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *cmap);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colors-store">gdk_colors_store</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colors, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> ncolors);<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-copy">gdk_color_copy</a> (const <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-free">gdk_color_free</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colors-alloc">gdk_colors_alloc</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> contiguous, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gulong">gulong</a> *planes, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> nplanes, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gulong">gulong</a> *pixels, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> npixels);void <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colors-free">gdk_colors_free</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gulong">gulong</a> *pixels, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> npixels, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gulong">gulong</a> planes);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-white">gdk_color_white</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-black">gdk_color_black</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-parse">gdk_color_parse</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *spec, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-alloc">gdk_color_alloc</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-change">gdk_color_change</a> (<a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a> *colormap, <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-equal">gdk_color_equal</a> (const <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colora, const <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colorb);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-hash">gdk_color_hash</a> (const <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *colora);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-to-string">gdk_color_to_string</a> (const <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *color);</pre></div><div class="refsect1" lang="en"><a name="id3146148"></a><h2>Description</h2><p>These functions are used to modify colormaps.A colormap is an object that contains the mappingbetween the color values stored in memory andthe RGB values that are used to display colorvalues. In general, colormaps only containsignificant information for pseudo-color visuals,but even for other visual types, a colormap objectis required in some circumstances.</p><p>There are a couple of special colormaps that canbe retrieved. The system colormap (retrieved with <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-colormap-get-system"><code class="function">gdk_colormap_get_system()</code></a>) is the defaultcolormap of the system. If you are using GdkRGB,there is another colormap that is important - thecolormap in which GdkRGB works, retrieved with<a class="link" href="gdk-GdkRGB.html#gdk-rgb-get-colormap"><code class="function">gdk_rgb_get_colormap()</code></a>. However, when using GdkRGB, it is not generally necessary to allocate colorsdirectly.</p><p>In previous revisions of this interface, a numberof functions that take a <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap"><span class="type">GdkColormap</span></a> parameterwere replaced with functions whose names beganwith "gdk_colormap_". This process will probablybe extended somewhat in the future - <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-white"><code class="function">gdk_color_white()</code></a>, <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-black"><code class="function">gdk_color_black()</code></a>, and <a class="link" href="gdk-Colormaps-and-Colors.html#gdk-color-change"><code class="function">gdk_color_change()</code></a> will probably become aliases.</p></div><div class="refsect1" lang="en"><a name="id3146247"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3146258"></a><h3><a name="GdkColor"></a>GdkColor</h3><a class="indexterm" name="id3146270"></a><pre class="programlisting">typedef struct { guint32 pixel; guint16 red; guint16 green; guint16 blue;} GdkColor;</pre><p>The <a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor"><span class="type">GdkColor</span></a> structure is used to describe an allocated or unallocated color.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a> <em class="structfield"><code>pixel</code></em>;</span></p></td><td>For allocated colors, the value used to draw this color on the screen.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16">guint16</a> <em class="structfield"><code>red</code></em>;</span></p></td><td>The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensitiy.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16">guint16</a> <em class="structfield"><code>green</code></em>;</span></p></td><td>The blue component of the color.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint16">guint16</a> <em class="structfield"><code>blue</code></em>;</span></p></td><td>The green component of the color.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3146384"></a><h3><a name="GdkColormap"></a>GdkColormap</h3><a class="indexterm" name="id3146396"></a><pre class="programlisting">typedef struct { gint size; GdkColor *colors;} GdkColormap;</pre><p>The colormap structure contains the following public fields.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>size</code></em>;</span></p></td><td>For pseudo-color colormaps, the number of colors in the colormap.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Colormaps-and-Colors.html#GdkColor">GdkColor</a> *<em class="structfield"><code>colors</code></em>;</span></p></td><td>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.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3146462"></a><h3><a name="gdk-colormap-new"></a>gdk_colormap_new ()</h3><a class="indexterm" name="id3146475"></a><pre class="programlisting"><a class="link" href="gdk-Colormaps-and-Colors.html#GdkColormap">GdkColormap</a>* gdk_colormap_new (<a class="link" href="gdk-Visuals.html#GdkVisual">GdkVisual</a> *visual, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> allocate);</pre><p>Creates a new colormap for the given visual.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>visual</code></em> :</span></p></td><td> a <a class="link" href="gdk-Visuals.html#GdkVisual"><span class="type">GdkVisual</span></a>.</td></tr><tr>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -