Criar  Editar  FrontPage  Índices  Buscar  Alterações  History  RSS  Login

Gdk::Colormap

class Gdk::Colormap

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.

Class Methods

Gdk::Colormap.new(visual, allocate)
Creates a new colormap for the given visual.
  • visual: a Gdk::Visual.
  • allocate: if true, the newly created colormap will be a private colormap, and all colors in it will be allocated for the applications use.
  • Returns: the new Gdk::Colormap.
Gdk::Colormap.system
Returns the system's default colormap.

Instance Methods

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.
free_color(color)
Frees a previously allocated color.
  • color: the color(Gdk::Color) to free.
  • Returns: self
query_color(pixel)
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
visual
Returns the visual for which a given colormap was created.
colors
Returns an Array containing the current values(Gdk::Color) in the colormap.
  • Returns: self