Next: , Previous: Colormaps and Colors, Up: Top


14 Visuals

Low-level display hardware information

14.1 Overview

A <gdk-visual> describes a particular video hardware display format. It includes information about the number of bits used for each color, the way the bits are translated into an RGB value for display, and the way the bits are stored in memory. For example, a piece of display hardware might support 24-bit color, 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given pixel size, pixels can be in different formats; for example the "red" element of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower 4 bits.

Usually you can avoid thinking about visuals in GTK+. Visuals are useful to interpret the contents of a <gdk-image>, but you should avoid <gdk-image> precisely because its contents depend on the display hardware; use <gdk-pixbuf> instead, for all but the most low-level purposes. Also, anytime you provide a <gdk-colormap>, the visual is implied as part of the colormap (gdk-colormap-get-visual), so you won't have to provide a visual in addition.

There are several standard visuals. The visual returned by gdk-visual-get-system is the system's default visual. gdk-rgb-get-visual return the visual most suited to displaying full-color image data. If you use the calls in <gdk-rgb>, you should create your windows using this visual (and the colormap returned by gdk-rgb-get-colormap).

A number of functions are provided for determining the "best" available visual. For the purposes of making this determination, higher bit depths are considered better, and for visuals of the same bit depth, ‘GDK_VISUAL_PSEUDO_COLOR’ is preferred at 8bpp, otherwise, the visual types are ranked in the order of (highest to lowest) ‘GDK_VISUAL_DIRECT_COLOR’, ‘GDK_VISUAL_TRUE_COLOR’, ‘GDK_VISUAL_PSEUDO_COLOR’, ‘GDK_VISUAL_STATIC_COLOR’, ‘GDK_VISUAL_GRAYSCALE’, then ‘GDK_VISUAL_STATIC_GRAY’.

14.2 Usage

— Class: <gdk-visual>

Derives from <gobject>.

This class defines no direct slots.

— Function: gdk-list-visuals ⇒  (ret glist-of)

Lists the available visuals for the default screen. (See gdk-screen-list-visuals) A visual describes a hardware image data format. For example, a visual might support 24-bit color, or 8-bit color, and might expect pixels to be in a certain format.

Call g-list-free on the return value when you're finished with it.

ret
a list of visuals; the list must be freed, but not its contents
— Function: gdk-visual-get-best-depth ⇒  (ret int)

Get the best available depth for the default GDK screen. "Best" means "largest," i.e. 32 preferred over 24 preferred over 8 bits per pixel.

ret
best available depth
— Function: gdk-visual-get-best-type ⇒  (ret <gdk-visual-type>)

Return the best available visual type for the default GDK screen.

ret
best visual type
— Function: gdk-visual-get-system ⇒  (ret <gdk-visual>)

Get the system'sdefault visual for the default GDK screen. This is the visual for the root window of the display. The return value should not be freed.

ret
system visual
— Function: gdk-visual-get-best ⇒  (ret <gdk-visual>)

Get the visual with the most available colors for the default GDK screen. The return value should not be freed.

ret
best visual
— Function: gdk-visual-get-best-with-depth (depth int) ⇒  (ret <gdk-visual>)

Get the best visual with depth depth for the default GDK screen. Color visuals and visuals with mutable colormaps are preferred over grayscale or fixed-colormap visuals. The return value should not be freed. ‘#f’ may be returned if no visual supports depth.

depth
a bit depth
ret
best visual for the given depth
— Function: gdk-visual-get-best-with-type (visual_type <gdk-visual-type>) ⇒  (ret <gdk-visual>)

Get the best visual of the given visual-type for the default GDK screen. Visuals with higher color depths are considered better. The return value should not be freed. ‘#f’ may be returned if no visual has type visual-type.

visual-type
a visual type
ret
best visual of the given type
— Function: gdk-visual-get-best-with-both (depth int) (visual_type <gdk-visual-type>) ⇒  (ret <gdk-visual>)

Combines gdk-visual-get-best-with-depth and gdk-visual-get-best-with-type.

depth
a bit depth
visual-type
a visual type
ret
best visual with both depth and visual-type, or ‘#f’ if none
— Function: gdk-visual-get-screen (self <gdk-visual>) ⇒  (ret <gdk-screen>)
— Method: get-screen

Gets the screen to which this visual belongs

visual
a <gdk-visual>
ret
the screen to which this visual belongs.

Since 2.2