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.system) is the default colormap of the system. If you are using Gdk::RGB, there is another colormap that is important - the colormap in which Gdk::RGB works, retrieved with Gdk::RGB.colormap. However, when using Gdk::RGB, it is not generally necessary to allocate colors directly.
- Creates a new colormap for the given visual.
Returns the system's default colormap.
- Returns: the default colormap(Gdk::Colormap).
alloc_color(color, writeable, best_match)
Allocates a single color from a colormap.
- color: the color to allocate. On return the pixel field will be filled in if allocation succeeds.
- writeable: If true, the color is allocated writeable. Writeable colors cannot be shared between applications.
- best_match: If true, GDK will attempt to do matching against existing colors if the color cannot be allocated as requested.
- Returns: true if the allocation succeeded.
Frees a previously allocated color.
- color: the color(Gdk::Color) to free.
- Returns: self
Locates the RGB color in colormap corresponding to the given hardware pixel. pixel must be a valid pixel in the colormap; it's a programmer error to call this methodwith a pixel which is not in the colormap. Hardware pixels are normally obtained from Gdk::Colormap#alloc_color, or from a Gdk::Image. (A Gdk::Image contains image data in hardware format, a Gdk::Pixbuf contains image data in a canonical 24-bit RGB format.)
This method is rarely useful, it's used for example to implement the eyedropper feature in Gtk::ColorSelection.
- pixel: pixel value in hardware display format
- Returns: Gdk::Color with red, green, blue fields initialized
Returns the visual for which a given colormap was created.
- Returns: the Gdk::Visual of the colormap.
Returns an Array containing the current values(Gdk::Color) in the colormap.
- Returns: self