1 /* GDK - The GIMP Drawing Kit
4 * Copyright 2001 Sun Microsystems Inc.
6 * Erwann Chenede <erwann.chenede@sun.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 #include "gdkvisual.h"
28 #include "gdkscreen.h"
33 * @Short_description: Low-level display hardware information
36 * A #GdkVisual describes a particular video hardware display format. It includes
37 * information about the number of bits used for each color, the way the bits are
38 * translated into an RGB value for display, and the way the bits are stored in
39 * memory. For example, a piece of display hardware might support 24-bit color,
40 * 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given
41 * pixel size, pixels can be in different formats; for example the "red" element
42 * of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower
45 * There are several standard visuals. The visual returned by
46 * gdk_screen_get_system_visual() is the system's default visual.
48 * A number of functions are provided for determining the "best" available visual.
49 * For the purposes of making this determination, higher bit depths are considered
50 * better, and for visuals of the same bit depth, %GDK_VISUAL_PSEUDO_COLOR is
51 * preferred at 8bpp, otherwise, the visual types are ranked in the order of
52 * (highest to lowest) %GDK_VISUAL_DIRECT_COLOR, %GDK_VISUAL_TRUE_COLOR,
53 * %GDK_VISUAL_PSEUDO_COLOR, %GDK_VISUAL_STATIC_COLOR, %GDK_VISUAL_GRAYSCALE,
54 * then %GDK_VISUAL_STATIC_GRAY.
61 * Lists the available visuals for the default screen.
62 * (See gdk_screen_list_visuals())
63 * A visual describes a hardware image data format.
64 * For example, a visual might support 24-bit color, or 8-bit color,
65 * and might expect pixels to be in a certain format.
67 * Call g_list_free() on the return value when you're finished with it.
69 * Return value: (transfer container) (element-type GdkVisual):
70 * a list of visuals; the list must be freed, but not its contents
73 gdk_list_visuals (void)
75 return gdk_screen_list_visuals (gdk_screen_get_default ());
79 * gdk_visual_get_system:
81 * Get the system's default visual for the default GDK screen.
82 * This is the visual for the root window of the display.
83 * The return value should not be freed.
85 * Return value: (transfer none): system visual
88 gdk_visual_get_system (void)
90 return gdk_screen_get_system_visual (gdk_screen_get_default());
94 * gdk_visual_get_visual_type:
95 * @visual: A #GdkVisual.
97 * Returns the type of visual this is (PseudoColor, TrueColor, etc).
99 * Return value: A #GdkVisualType stating the type of @visual.
104 gdk_visual_get_visual_type (GdkVisual *visual)
106 g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
112 * gdk_visual_get_depth:
113 * @visual: A #GdkVisual.
115 * Returns the bit depth of this visual.
117 * Return value: The bit depth of this visual.
122 gdk_visual_get_depth (GdkVisual *visual)
124 g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
126 return visual->depth;
130 * gdk_visual_get_byte_order:
131 * @visual: A #GdkVisual.
133 * Returns the byte order of this visual.
135 * Return value: A #GdkByteOrder stating the byte order of @visual.
140 gdk_visual_get_byte_order (GdkVisual *visual)
142 g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
144 return visual->byte_order;
148 * gdk_visual_get_colormap_size:
149 * @visual: A #GdkVisual.
151 * Returns the size of a colormap for this visual.
153 * Return value: The size of a colormap that is suitable for @visual.
158 gdk_visual_get_colormap_size (GdkVisual *visual)
160 g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
162 return visual->colormap_size;
166 * gdk_visual_get_bits_per_rgb:
167 * @visual: a #GdkVisual
169 * Returns the number of significant bits per red, green and blue value.
171 * Return value: The number of significant bits per color value for @visual.
176 gdk_visual_get_bits_per_rgb (GdkVisual *visual)
178 g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
180 return visual->bits_per_rgb;
184 * gdk_visual_get_red_pixel_details:
185 * @visual: A #GdkVisual.
186 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
187 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
188 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
190 * Obtains values that are needed to calculate red pixel values in TrueColor
191 * and DirectColor. The "mask" is the significant bits within the pixel.
192 * The "shift" is the number of bits left we must shift a primary for it
193 * to be in position (according to the "mask"). Finally, "precision" refers
194 * to how much precision the pixel value contains for a particular primary.
199 gdk_visual_get_red_pixel_details (GdkVisual *visual,
204 g_return_if_fail (GDK_IS_VISUAL (visual));
207 *mask = visual->red_mask;
210 *shift = visual->red_shift;
213 *precision = visual->red_prec;
217 * gdk_visual_get_green_pixel_details:
218 * @visual: a #GdkVisual
219 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
220 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
221 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
223 * Obtains values that are needed to calculate green pixel values in TrueColor
224 * and DirectColor. The "mask" is the significant bits within the pixel.
225 * The "shift" is the number of bits left we must shift a primary for it
226 * to be in position (according to the "mask"). Finally, "precision" refers
227 * to how much precision the pixel value contains for a particular primary.
232 gdk_visual_get_green_pixel_details (GdkVisual *visual,
237 g_return_if_fail (GDK_IS_VISUAL (visual));
240 *mask = visual->green_mask;
243 *shift = visual->green_shift;
246 *precision = visual->green_prec;
250 * gdk_visual_get_blue_pixel_details:
251 * @visual: a #GdkVisual
252 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
253 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
254 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
256 * Obtains values that are needed to calculate blue pixel values in TrueColor
257 * and DirectColor. The "mask" is the significant bits within the pixel.
258 * The "shift" is the number of bits left we must shift a primary for it
259 * to be in position (according to the "mask"). Finally, "precision" refers
260 * to how much precision the pixel value contains for a particular primary.
265 gdk_visual_get_blue_pixel_details (GdkVisual *visual,
270 g_return_if_fail (GDK_IS_VISUAL (visual));
273 *mask = visual->blue_mask;
276 *shift = visual->blue_shift;
279 *precision = visual->blue_prec;