~ubuntu-branches/ubuntu/vivid/gdk-pixbuf/vivid

« back to all changes in this revision

Viewing changes to doc/sgml/rendering.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2004-10-06 22:10:04 UTC
  • Revision ID: james.westby@ubuntu.com-20041006221004-rma9deknj8qctu67
Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<refentry id="gdk-pixbuf-rendering">
 
2
<refmeta>
 
3
<refentrytitle>Rendering</refentrytitle>
 
4
<manvolnum>3</manvolnum>
 
5
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
 
6
</refmeta>
 
7
 
 
8
<refnamediv>
 
9
<refname>Rendering</refname><refpurpose>Rendering a pixbuf to a GDK drawable.</refpurpose>
 
10
</refnamediv>
 
11
 
 
12
<refsynopsisdiv><title>Synopsis</title>
 
13
<synopsis>
 
14
 
 
15
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;
 
16
 
 
17
 
 
18
enum        <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link>;
 
19
void        <link linkend="gdk-pixbuf-render-to-drawable-alpha">gdk_pixbuf_render_to_drawable_alpha</link>
 
20
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
21
                                             <link linkend="GdkDrawable">GdkDrawable</link> *drawable,
 
22
                                             int src_x,
 
23
                                             int src_y,
 
24
                                             int dest_x,
 
25
                                             int dest_y,
 
26
                                             int width,
 
27
                                             int height,
 
28
                                             <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
 
29
                                             int alpha_threshold,
 
30
                                             <link linkend="GdkRgbDither">GdkRgbDither</link> dither,
 
31
                                             int x_dither,
 
32
                                             int y_dither);
 
33
void        <link linkend="gdk-pixbuf-render-to-drawable">gdk_pixbuf_render_to_drawable</link>   (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
34
                                             <link linkend="GdkDrawable">GdkDrawable</link> *drawable,
 
35
                                             <link linkend="GdkGC">GdkGC</link> *gc,
 
36
                                             int src_x,
 
37
                                             int src_y,
 
38
                                             int dest_x,
 
39
                                             int dest_y,
 
40
                                             int width,
 
41
                                             int height,
 
42
                                             <link linkend="GdkRgbDither">GdkRgbDither</link> dither,
 
43
                                             int x_dither,
 
44
                                             int y_dither);
 
45
void        <link linkend="gdk-pixbuf-render-threshold-alpha">gdk_pixbuf_render_threshold_alpha</link>
 
46
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
47
                                             <link linkend="GdkBitmap">GdkBitmap</link> *bitmap,
 
48
                                             int src_x,
 
49
                                             int src_y,
 
50
                                             int dest_x,
 
51
                                             int dest_y,
 
52
                                             int width,
 
53
                                             int height,
 
54
                                             int alpha_threshold);
 
55
void        <link linkend="gdk-pixbuf-render-pixmap-and-mask">gdk_pixbuf_render_pixmap_and_mask</link>
 
56
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
57
                                             <link linkend="GdkPixmap">GdkPixmap</link> **pixmap_return,
 
58
                                             <link linkend="GdkBitmap">GdkBitmap</link> **mask_return,
 
59
                                             int alpha_threshold);
 
60
</synopsis>
 
61
</refsynopsisdiv>
 
62
 
 
63
 
 
64
 
 
65
 
 
66
 
 
67
<refsect1>
 
68
<title>Description</title>
 
69
  <para>
 
70
    The &gdk-pixbuf; library provides several convenience functions to
 
71
    render pixbufs to GDK drawables.  It uses the GdkRGB to render the
 
72
    image data.
 
73
  </para>
 
74
 
 
75
  <para>
 
76
    At this point there is not a standard alpha channel extension for
 
77
    the X Window System, so it is not possible to use full opacity
 
78
    information when painting images to arbitrary drawables.  The
 
79
    &gdk-pixbuf; convenience functions will threshold the opacity
 
80
    information to create a bi-level clipping mask (black and white),
 
81
    and use that to draw the image onto a drawable.
 
82
  </para>
 
83
 
 
84
  <important>
 
85
    <para>
 
86
      Since these functions use GdkRGB for rendering, you must
 
87
      initialize GdkRGB before using any of them.  You can do this by
 
88
      calling <link linkend="gdk-rgb-init">gdk_rgb_init</link>() near the beginning of your program.
 
89
    </para>
 
90
  </important>
 
91
</refsect1>
 
92
 
 
93
<refsect1>
 
94
<title>Details</title>
 
95
<refsect2>
 
96
<title><anchor id="GdkPixbufAlphaMode">enum GdkPixbufAlphaMode</title>
 
97
<programlisting>typedef enum {
 
98
        GDK_PIXBUF_ALPHA_BILEVEL,
 
99
        GDK_PIXBUF_ALPHA_FULL
 
100
} GdkPixbufAlphaMode;
 
101
</programlisting>
 
102
  <para>
 
103
    These values can be passed to
 
104
    <link linkend="gdk-pixbuf-render-to-drawable-alpha">gdk_pixbuf_render_to_drawable_alpha</link>() to control how the alpha
 
105
    chanel of an image should be handled.  This function can create a
 
106
    bilevel clipping mask (black and white) and use it while painting
 
107
    the image.  In the future, when the X Window System gets an alpha
 
108
    channel extension, it will be possible to do full alpha
 
109
    compositing onto arbitrary drawables.  For now both cases fall
 
110
    back to a bilevel clipping mask.
 
111
  </para><informaltable pgwide=1 frame="none" role="enum">
 
112
<tgroup cols="2">
 
113
<colspec colwidth="2*">
 
114
<colspec colwidth="8*">
 
115
<tbody>
 
116
<row>
 
117
<entry><literal>GDK_PIXBUF_ALPHA_BILEVEL</literal></entry>
 
118
<entry>A bilevel clipping mask (black and white)
 
119
will be created and used to draw the image.  Pixels below 0.5 opacity
 
120
will be considered fully transparent, and all others will be
 
121
considered fully opaque.
 
122
</entry>
 
123
</row>
 
124
<row>
 
125
<entry><literal>GDK_PIXBUF_ALPHA_FULL</literal></entry>
 
126
<entry>For now falls back to <link linkend="GDK-PIXBUF-ALPHA-BILEVEL-CAPS">GDK_PIXBUF_ALPHA_BILEVEL</link>.
 
127
In the future it will do full alpha compositing.
 
128
 
 
129
</entry>
 
130
</row>
 
131
</tbody></tgroup></informaltable></refsect2>
 
132
<refsect2>
 
133
<title><anchor id="gdk-pixbuf-render-to-drawable-alpha">gdk_pixbuf_render_to_drawable_alpha ()</title>
 
134
<programlisting>void        gdk_pixbuf_render_to_drawable_alpha
 
135
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
136
                                             <link linkend="GdkDrawable">GdkDrawable</link> *drawable,
 
137
                                             int src_x,
 
138
                                             int src_y,
 
139
                                             int dest_x,
 
140
                                             int dest_y,
 
141
                                             int width,
 
142
                                             int height,
 
143
                                             <link linkend="GdkPixbufAlphaMode">GdkPixbufAlphaMode</link> alpha_mode,
 
144
                                             int alpha_threshold,
 
145
                                             <link linkend="GdkRgbDither">GdkRgbDither</link> dither,
 
146
                                             int x_dither,
 
147
                                             int y_dither);</programlisting>
 
148
<para>
 
149
Renders a rectangular portion of a pixbuf to a drawable.  This is done using
 
150
GdkRGB, so the specified drawable must have the GdkRGB visual and colormap.
 
151
</para>
 
152
<para>
 
153
When used with <link linkend="GDK-PIXBUF-ALPHA-BILEVEL-CAPS">GDK_PIXBUF_ALPHA_BILEVEL</link>, this function has to create a bitmap
 
154
out of the thresholded alpha channel of the image and, it has to set this
 
155
bitmap as the clipping mask for the GC used for drawing.  This can be a
 
156
significant performance penalty depending on the size and the complexity of
 
157
the alpha channel of the image.  If performance is crucial, consider handling
 
158
the alpha channel yourself (possibly by caching it in your application) and
 
159
using <link linkend="gdk-pixbuf-render-to-drawable">gdk_pixbuf_render_to_drawable</link>() or GdkRGB directly instead.</para>
 
160
<para>
 
161
 
 
162
</para><informaltable pgwide=1 frame="none" role="params">
 
163
<tgroup cols="2">
 
164
<colspec colwidth="2*">
 
165
<colspec colwidth="8*">
 
166
<tbody>
 
167
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
 
168
<entry> A pixbuf.
 
169
</entry></row>
 
170
<row><entry align="right"><parameter>drawable</parameter>&nbsp;:</entry>
 
171
<entry> Destination drawable.
 
172
</entry></row>
 
173
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
 
174
<entry> Source X coordinate within pixbuf.
 
175
</entry></row>
 
176
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
 
177
<entry> Source Y coordinates within pixbuf.
 
178
</entry></row>
 
179
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
 
180
<entry> Destination X coordinate within drawable.
 
181
</entry></row>
 
182
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
 
183
<entry> Destination Y coordinate within drawable.
 
184
</entry></row>
 
185
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
 
186
<entry> Width of region to render, in pixels.
 
187
</entry></row>
 
188
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
 
189
<entry> Height of region to render, in pixels.
 
190
</entry></row>
 
191
<row><entry align="right"><parameter>alpha_mode</parameter>&nbsp;:</entry>
 
192
<entry> If the image does not have opacity information, this is ignored.
 
193
Otherwise, specifies how to handle transparency when rendering.
 
194
</entry></row>
 
195
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
 
196
<entry> If the image does have opacity information and <parameter>alpha_mode</parameter>
 
197
is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity
 
198
values.
 
199
</entry></row>
 
200
<row><entry align="right"><parameter>dither</parameter>&nbsp;:</entry>
 
201
<entry> Dithering mode for GdkRGB.
 
202
</entry></row>
 
203
<row><entry align="right"><parameter>x_dither</parameter>&nbsp;:</entry>
 
204
<entry> X offset for dither.
 
205
</entry></row>
 
206
<row><entry align="right"><parameter>y_dither</parameter>&nbsp;:</entry>
 
207
<entry> Y offset for dither.
 
208
</entry></row>
 
209
</tbody></tgroup></informaltable></refsect2>
 
210
<refsect2>
 
211
<title><anchor id="gdk-pixbuf-render-to-drawable">gdk_pixbuf_render_to_drawable ()</title>
 
212
<programlisting>void        gdk_pixbuf_render_to_drawable   (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
213
                                             <link linkend="GdkDrawable">GdkDrawable</link> *drawable,
 
214
                                             <link linkend="GdkGC">GdkGC</link> *gc,
 
215
                                             int src_x,
 
216
                                             int src_y,
 
217
                                             int dest_x,
 
218
                                             int dest_y,
 
219
                                             int width,
 
220
                                             int height,
 
221
                                             <link linkend="GdkRgbDither">GdkRgbDither</link> dither,
 
222
                                             int x_dither,
 
223
                                             int y_dither);</programlisting>
 
224
<para>
 
225
Renders a rectangular portion of a pixbuf to a drawable while using the
 
226
specified GC.  This is done using GdkRGB, so the specified drawable must have
 
227
the GdkRGB visual and colormap.  Note that this function will ignore the
 
228
opacity information for images with an alpha channel; the GC must already
 
229
have the clipping mask set if you want transparent regions to show through.
 
230
</para>
 
231
<para>
 
232
For an explanation of dither offsets, see the GdkRGB documentation.  In
 
233
brief, the dither offset is important when re-rendering partial regions of an
 
234
image to a rendered version of the full image, or for when the offsets to a
 
235
base position change, as in scrolling.  The dither matrix has to be shifted
 
236
for consistent visual results.  If you do not have any of these cases, the
 
237
dither offsets can be both zero.</para>
 
238
<para>
 
239
 
 
240
</para><informaltable pgwide=1 frame="none" role="params">
 
241
<tgroup cols="2">
 
242
<colspec colwidth="2*">
 
243
<colspec colwidth="8*">
 
244
<tbody>
 
245
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
 
246
<entry> A pixbuf.
 
247
</entry></row>
 
248
<row><entry align="right"><parameter>drawable</parameter>&nbsp;:</entry>
 
249
<entry> Destination drawable.
 
250
</entry></row>
 
251
<row><entry align="right"><parameter>gc</parameter>&nbsp;:</entry>
 
252
<entry> GC used for rendering.
 
253
</entry></row>
 
254
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
 
255
<entry> Source X coordinate within pixbuf.
 
256
</entry></row>
 
257
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
 
258
<entry> Source Y coordinate within pixbuf.
 
259
</entry></row>
 
260
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
 
261
<entry> Destination X coordinate within drawable.
 
262
</entry></row>
 
263
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
 
264
<entry> Destination Y coordinate within drawable.
 
265
</entry></row>
 
266
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
 
267
<entry> Width of region to render, in pixels.
 
268
</entry></row>
 
269
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
 
270
<entry> Height of region to render, in pixels.
 
271
</entry></row>
 
272
<row><entry align="right"><parameter>dither</parameter>&nbsp;:</entry>
 
273
<entry> Dithering mode for GdkRGB.
 
274
</entry></row>
 
275
<row><entry align="right"><parameter>x_dither</parameter>&nbsp;:</entry>
 
276
<entry> X offset for dither.
 
277
</entry></row>
 
278
<row><entry align="right"><parameter>y_dither</parameter>&nbsp;:</entry>
 
279
<entry> Y offset for dither.
 
280
</entry></row>
 
281
</tbody></tgroup></informaltable></refsect2>
 
282
<refsect2>
 
283
<title><anchor id="gdk-pixbuf-render-threshold-alpha">gdk_pixbuf_render_threshold_alpha ()</title>
 
284
<programlisting>void        gdk_pixbuf_render_threshold_alpha
 
285
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
286
                                             <link linkend="GdkBitmap">GdkBitmap</link> *bitmap,
 
287
                                             int src_x,
 
288
                                             int src_y,
 
289
                                             int dest_x,
 
290
                                             int dest_y,
 
291
                                             int width,
 
292
                                             int height,
 
293
                                             int alpha_threshold);</programlisting>
 
294
<para>
 
295
Takes the opacity values in a rectangular portion of a pixbuf and thresholds
 
296
them to produce a bi-level alpha mask that can be used as a clipping mask for
 
297
a drawable.</para>
 
298
<para>
 
299
 
 
300
</para><informaltable pgwide=1 frame="none" role="params">
 
301
<tgroup cols="2">
 
302
<colspec colwidth="2*">
 
303
<colspec colwidth="8*">
 
304
<tbody>
 
305
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
 
306
<entry> A pixbuf.
 
307
</entry></row>
 
308
<row><entry align="right"><parameter>bitmap</parameter>&nbsp;:</entry>
 
309
<entry> Bitmap where the bilevel mask will be painted to.
 
310
</entry></row>
 
311
<row><entry align="right"><parameter>src_x</parameter>&nbsp;:</entry>
 
312
<entry> Source X coordinate.
 
313
</entry></row>
 
314
<row><entry align="right"><parameter>src_y</parameter>&nbsp;:</entry>
 
315
<entry> source Y coordinate.
 
316
</entry></row>
 
317
<row><entry align="right"><parameter>dest_x</parameter>&nbsp;:</entry>
 
318
<entry> Destination X coordinate.
 
319
</entry></row>
 
320
<row><entry align="right"><parameter>dest_y</parameter>&nbsp;:</entry>
 
321
<entry> Destination Y coordinate.
 
322
</entry></row>
 
323
<row><entry align="right"><parameter>width</parameter>&nbsp;:</entry>
 
324
<entry> Width of region to threshold.
 
325
</entry></row>
 
326
<row><entry align="right"><parameter>height</parameter>&nbsp;:</entry>
 
327
<entry> Height of region to threshold.
 
328
</entry></row>
 
329
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
 
330
<entry> Opacity values below this will be painted as zero; all
 
331
other values will be painted as one.
 
332
</entry></row>
 
333
</tbody></tgroup></informaltable></refsect2>
 
334
<refsect2>
 
335
<title><anchor id="gdk-pixbuf-render-pixmap-and-mask">gdk_pixbuf_render_pixmap_and_mask ()</title>
 
336
<programlisting>void        gdk_pixbuf_render_pixmap_and_mask
 
337
                                            (<link linkend="GdkPixbuf">GdkPixbuf</link> *pixbuf,
 
338
                                             <link linkend="GdkPixmap">GdkPixmap</link> **pixmap_return,
 
339
                                             <link linkend="GdkBitmap">GdkBitmap</link> **mask_return,
 
340
                                             int alpha_threshold);</programlisting>
 
341
<para>
 
342
Creates a pixmap and a mask bitmap which are returned in the <parameter>pixmap_return</parameter>
 
343
and <parameter>mask_return</parameter> arguments, respectively, and renders a pixbuf and its
 
344
corresponding tresholded alpha mask to them.  This is merely a convenience
 
345
function; applications that need to render pixbufs with dither offsets or to
 
346
given drawables should use <link linkend="gdk-pixbuf-render-to-drawable-alpha">gdk_pixbuf_render_to_drawable_alpha</link>() or
 
347
<link linkend="gdk-pixbuf-render-to-drawable">gdk_pixbuf_render_to_drawable</link>(), and <link linkend="gdk-pixbuf-render-threshold-alpha">gdk_pixbuf_render_threshold_alpha</link>().
 
348
</para>
 
349
<para>
 
350
If the pixbuf does not have an alpha channel, then *<parameter>mask_return</parameter> will be set
 
351
to <literal>NULL</literal>.</para>
 
352
<para>
 
353
 
 
354
</para><informaltable pgwide=1 frame="none" role="params">
 
355
<tgroup cols="2">
 
356
<colspec colwidth="2*">
 
357
<colspec colwidth="8*">
 
358
<tbody>
 
359
<row><entry align="right"><parameter>pixbuf</parameter>&nbsp;:</entry>
 
360
<entry> A pixbuf.
 
361
</entry></row>
 
362
<row><entry align="right"><parameter>pixmap_return</parameter>&nbsp;:</entry>
 
363
<entry> Return value for the created pixmap.
 
364
</entry></row>
 
365
<row><entry align="right"><parameter>mask_return</parameter>&nbsp;:</entry>
 
366
<entry> Return value for the created mask.
 
367
</entry></row>
 
368
<row><entry align="right"><parameter>alpha_threshold</parameter>&nbsp;:</entry>
 
369
<entry> Threshold value for opacity values.
 
370
</entry></row>
 
371
</tbody></tgroup></informaltable></refsect2>
 
372
 
 
373
</refsect1>
 
374
 
 
375
 
 
376
 
 
377
<refsect1>
 
378
<title>See Also</title>
 
379
  <para>
 
380
    GdkRGB
 
381
  </para>
 
382
</refsect1>
 
383
 
 
384
</refentry>