summaryrefslogtreecommitdiff
path: root/docs/reference/gdk/tmpl/visuals.sgml
blob: 73892502453ff1662b7a6adf79a86beb1393dd9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!-- ##### SECTION Title ##### -->
Visuals

<!-- ##### SECTION Short_Description ##### -->

Low-level display hardware information

<!-- ##### SECTION Long_Description ##### -->
<para>
A #GdkVisual 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.
</para>
<para>
Usually you can avoid thinking about visuals in GTK+. Visuals are useful to
interpret the contents of a #GdkImage, but you should avoid #GdkImage precisely
because its contents depend on the display hardware; use #GdkPixbuf instead, for
all but the most low-level purposes. Also, anytime you provide a #GdkColormap,
the visual is implied as part of the colormap (gdk_colormap_get_visual()), so
you won't have to provide a visual in addition.
</para>
<para>
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 #GdkRGB, you should create your windows
using this visual (and the colormap returned by
gdk_rgb_get_colormap()).
</para>
<para>
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.
</para>

<!-- ##### SECTION See_Also ##### -->
<para>
#GdkImage, #GdkColormap, #GdkRGB
</para>

<!-- ##### SECTION Stability_Level ##### -->


<!-- ##### SECTION Image ##### -->


<!-- ##### STRUCT GdkVisual ##### -->
<para>
The <type>GdkVisual</type> structure contains information about
a particular visual.
</para>

<example id="rgbmask">
<title>Constructing a pixel value from components</title>
<programlisting>
guint
pixel_from_rgb (GdkVisual *visual,
                guchar r, guchar b, guchar g)
{
  return ((r &gt;&gt; (16 - visual-&gt;red_prec))   &lt;&lt; visual-&gt;red_shift) |
         ((g &gt;&gt; (16 - visual-&gt;green_prec)) &lt;&lt; visual-&gt;green_shift) |
         ((r &gt;&gt; (16 - visual-&gt;blue_prec))  &lt;&lt; visual-&gt;blue_shift);
}
</programlisting>
</example>

@parent_instance: inherited portion from #GObject

<!-- ##### ENUM GdkVisualType ##### -->
<para>
A set of values that describe the manner in which the
pixel values for a visual are converted into RGB
values for display.
</para>

@GDK_VISUAL_STATIC_GRAY: Each pixel value indexes a grayscale value directly.
@GDK_VISUAL_GRAYSCALE: Each pixel is an index into a color map that maps pixel 
   values into grayscale values. The color map can be changed by an application.
@GDK_VISUAL_STATIC_COLOR: Each pixel value is an index into a predefined,
   unmodifiable color map that maps pixel values into RGB values.
@GDK_VISUAL_PSEUDO_COLOR: Each pixel is an index into a color map that maps
   pixel values into rgb values. The color map can be changed by an application.
@GDK_VISUAL_TRUE_COLOR: Each pixel value directly contains red, green,
   and blue components. The <structfield>red_mask</structfield>,
   <structfield>green_mask</structfield>, and 
   <structfield>blue_mask</structfield> fields of the #GdkVisual
   structure describe how the components are assembled into a pixel value.
@GDK_VISUAL_DIRECT_COLOR: Each pixel value contains red, green, and blue
   components as for %GDK_VISUAL_TRUE_COLOR, but the components are mapped via a 
   color table into the final output table instead of being converted directly.

<!-- ##### ENUM GdkByteOrder ##### -->
<para>
A set of values describing the possible byte-orders
for storing pixel values in memory.
</para>

@GDK_LSB_FIRST: The values are stored with the least-significant byte
  first. For instance, the 32-bit value 0xffeecc would be stored
  in memory as 0xcc, 0xee, 0xff, 0x00.
@GDK_MSB_FIRST: The values are stored with the most-significant byte
first. For instance, the 32-bit value 0xffeecc would be stored
in memory as 0x00, 0xcc, 0xee, 0xff.

<!-- ##### FUNCTION gdk_query_depths ##### -->
<para>

</para>

@depths: 
@count: 


<!-- ##### FUNCTION gdk_query_visual_types ##### -->
<para>

</para>

@visual_types: 
@count: 


<!-- ##### FUNCTION gdk_list_visuals ##### -->
<para>

</para>

@void: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best_depth ##### -->
<para>

</para>

@void: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best_type ##### -->
<para>

</para>

@void: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_system ##### -->
<para>

</para>

@void: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best ##### -->
<para>

</para>

@void: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best_with_depth ##### -->
<para>

</para>

@depth: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best_with_type ##### -->
<para>

</para>

@visual_type: 
@Returns: 


<!-- ##### FUNCTION gdk_visual_get_best_with_both ##### -->
<para>

</para>

@depth: 
@visual_type: 
@Returns: 


<!-- ##### MACRO gdk_visual_ref ##### -->
<para>
Deprecated equivalent of g_object_ref().
</para>

@v: a #GdkVisual
@Returns: the same visual


<!-- ##### MACRO gdk_visual_unref ##### -->
<para>
Deprecated equivalent of g_object_unref().
</para>

@v: a #GdkVisual


<!-- ##### FUNCTION gdk_visual_get_screen ##### -->
<para>

</para>

@visual: 
@Returns: