~ubuntu-branches/ubuntu/maverick/gdk-pixbuf/maverick

« back to all changes in this revision

Viewing changes to doc/html/x3767.html

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-07-23 11:26:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100723112625-owhl395g8ifk2wtn
Tags: 2.21.6-2ubuntu1
* Rebase on Debian
* debian/control, debian/gir1.0-gdkpixbuf-2.0.install, debian/rules:
  - build a gir1.0-gdkpixbuf-2.0 gir binary

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<HTML
2
 
><HEAD
3
 
><TITLE
4
 
>Converting Applications to gdk-pixbuf</TITLE
5
 
><META
6
 
NAME="GENERATOR"
7
 
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8
 
"><LINK
9
 
REL="HOME"
10
 
TITLE="The gdk-pixbuf Library"
11
 
HREF="index.html"><LINK
12
 
REL="UP"
13
 
TITLE="Porting applications from Imlib to gdk-pixbuf"
14
 
HREF="a3696.html"><LINK
15
 
REL="PREVIOUS"
16
 
TITLE="Differences between Imlib and gdk-pixbuf"
17
 
HREF="x3715.html"><LINK
18
 
REL="NEXT"
19
 
TITLE="Compiling the gdk-pixbuf library"
20
 
HREF="compiling.html"></HEAD
21
 
><BODY
22
 
CLASS="SECT1"
23
 
BGCOLOR="#FFFFFF"
24
 
TEXT="#000000"
25
 
LINK="#0000FF"
26
 
VLINK="#840084"
27
 
ALINK="#0000FF"
28
 
><DIV
29
 
CLASS="NAVHEADER"
30
 
><TABLE
31
 
WIDTH="100%"
32
 
BORDER="0"
33
 
BGCOLOR="#000000"
34
 
CELLPADDING="1"
35
 
CELLSPACING="0"
36
 
><TR
37
 
><TH
38
 
COLSPAN="4"
39
 
ALIGN="center"
40
 
><FONT
41
 
COLOR="#FFFFFF"
42
 
SIZE="5"
43
 
>The <SPAN
44
 
CLASS="APPLICATION"
45
 
>gdk-pixbuf</SPAN
46
 
> Library</FONT
47
 
></TH
48
 
></TR
49
 
><TR
50
 
><TD
51
 
WIDTH="25%"
52
 
BGCOLOR="#C00000"
53
 
ALIGN="left"
54
 
><A
55
 
HREF="x3715.html"
56
 
><FONT
57
 
COLOR="#FFFFFF"
58
 
SIZE="3"
59
 
><B
60
 
>&#60;&#60;&#60; Previous Page</B
61
 
></FONT
62
 
></A
63
 
></TD
64
 
><TD
65
 
WIDTH="25%"
66
 
BGCOLOR="#0000C0"
67
 
ALIGN="center"
68
 
><FONT
69
 
COLOR="#FFFFFF"
70
 
SIZE="3"
71
 
><B
72
 
><A
73
 
HREF="index.html"
74
 
><FONT
75
 
COLOR="#FFFFFF"
76
 
SIZE="3"
77
 
><B
78
 
>Home</B
79
 
></FONT
80
 
></A
81
 
></B
82
 
></FONT
83
 
></TD
84
 
><TD
85
 
WIDTH="25%"
86
 
BGCOLOR="#00C000"
87
 
ALIGN="center"
88
 
><FONT
89
 
COLOR="#FFFFFF"
90
 
SIZE="3"
91
 
><B
92
 
><A
93
 
HREF="a3696.html"
94
 
><FONT
95
 
COLOR="#FFFFFF"
96
 
SIZE="3"
97
 
><B
98
 
>Up</B
99
 
></FONT
100
 
></A
101
 
></B
102
 
></FONT
103
 
></TD
104
 
><TD
105
 
WIDTH="25%"
106
 
BGCOLOR="#C00000"
107
 
ALIGN="right"
108
 
><A
109
 
HREF="compiling.html"
110
 
><FONT
111
 
COLOR="#FFFFFF"
112
 
SIZE="3"
113
 
><B
114
 
>Next Page &#62;&#62;&#62;</B
115
 
></FONT
116
 
></A
117
 
></TD
118
 
></TR
119
 
></TABLE
120
 
></DIV
121
 
><BR
122
 
CLEAR="all"><DIV
123
 
CLASS="SECT1"
124
 
><H1
125
 
CLASS="SECT1"
126
 
><A
127
 
NAME="AEN3767">Converting Applications to <SPAN
128
 
CLASS="APPLICATION"
129
 
>gdk-pixbuf</SPAN
130
 
></H1
131
 
><P
132
 
>       This sections describes the actual changes you need to make in
133
 
        an <SPAN
134
 
CLASS="APPLICATION"
135
 
>Imlib</SPAN
136
 
> program to make it use <SPAN
137
 
CLASS="APPLICATION"
138
 
>gdk-pixbuf</SPAN
139
 
> instead.
140
 
      </P
141
 
><BR
142
 
CLEAR="all"><DIV
143
 
CLASS="SECT2"
144
 
><H2
145
 
CLASS="SECT2"
146
 
><A
147
 
NAME="AEN3773">Image loading and creation</H2
148
 
><P
149
 
>         The <SPAN
150
 
CLASS="APPLICATION"
151
 
>gdk-pixbuf</SPAN
152
 
> library can load image files synchronously
153
 
          (i.e. with a single function call), create images from RGB
154
 
          data in memory, and as a convenience, it can also create
155
 
          images from inline XPM data.
156
 
        </P
157
 
><P
158
 
>         To load an image file in a single function call, simply use
159
 
          <TT
160
 
CLASS="FUNCTION"
161
 
>gdk_pixbuf_new_from_file()</TT
162
 
>.  Note that
163
 
          this will make the program block until the whole file has
164
 
          been read.  This function effectively replaces
165
 
          <TT
166
 
CLASS="FUNCTION"
167
 
>gdk_imlib_load_image()</TT
168
 
>.
169
 
        </P
170
 
><P
171
 
>         If you have RGB data in memory, you can use
172
 
          <TT
173
 
CLASS="FUNCTION"
174
 
>gdk_pixbuf_new_from_data()</TT
175
 
> to create a
176
 
          pixbuf out of it; this is a replacement for
177
 
          <TT
178
 
CLASS="FUNCTION"
179
 
>gdk_imlib_create_image_from_data()</TT
180
 
>.
181
 
          <SPAN
182
 
CLASS="APPLICATION"
183
 
>gdk-pixbuf</SPAN
184
 
> does not copy the image data; it is up to you
185
 
          to define the ownership policy by providing a destroy
186
 
          notification function that will be called when the image
187
 
          data needs to be freed.  The function you provide can then
188
 
          free the data or do something else, as appropriate.
189
 
        </P
190
 
><P
191
 
>         As a convenience, you can use the
192
 
          <TT
193
 
CLASS="FUNCTION"
194
 
>gdk_pixbuf_new_from_xpm_data()</TT
195
 
> function
196
 
          to create a pixbuf out of inline XPM data that was compiled
197
 
          into your C program.  This is a replacement for
198
 
          <TT
199
 
CLASS="FUNCTION"
200
 
>gdk_imlib_create_image_from_xpm_data()</TT
201
 
>.
202
 
        </P
203
 
><P
204
 
>         After you have created a pixbuf, you can manipulate it in
205
 
          any way you please and then finally call
206
 
          <TT
207
 
CLASS="FUNCTION"
208
 
>gdk_pixbuf_unref()</TT
209
 
> when you are done
210
 
          with it.  This can be thought of as a replacement for
211
 
          <TT
212
 
CLASS="FUNCTION"
213
 
>gdk_imlib_destroy_image()</TT
214
 
> but with much
215
 
          cleaner semantics.
216
 
        </P
217
 
></DIV
218
 
><BR
219
 
CLEAR="all"><DIV
220
 
CLASS="SECT2"
221
 
><H2
222
 
CLASS="SECT2"
223
 
><A
224
 
NAME="AEN3790">Rendering Images</H2
225
 
><P
226
 
>         Applications that use <SPAN
227
 
CLASS="APPLICATION"
228
 
>Imlib</SPAN
229
 
> must first call
230
 
          <TT
231
 
CLASS="FUNCTION"
232
 
>gdk_imlib_render()</TT
233
 
> to render the whole
234
 
          image data onto a pixmap that <SPAN
235
 
CLASS="APPLICATION"
236
 
>Imlib</SPAN
237
 
> creates.  Then they
238
 
          must copy that pixmap's data into the final destination for
239
 
          the image.
240
 
        </P
241
 
><P
242
 
>         In contrast, <SPAN
243
 
CLASS="APPLICATION"
244
 
>gdk-pixbuf</SPAN
245
 
> provides convenience functions to
246
 
          render arbitrary rectangular regions of an image onto a
247
 
          drawable that your application provides.  You can use
248
 
          <TT
249
 
CLASS="FUNCTION"
250
 
>gdk_pixbuf_render_to_drawable()</TT
251
 
> or
252
 
          <TT
253
 
CLASS="FUNCTION"
254
 
>gdk_pixbuf_render_to_drawable_alpha()</TT
255
 
>
256
 
          to do this; having your application provide the destination
257
 
          drawable and specify an arbitrary region means your
258
 
          application has complete control over the way images are
259
 
          rendered.
260
 
        </P
261
 
><P
262
 
>         As a convenience, <SPAN
263
 
CLASS="APPLICATION"
264
 
>gdk-pixbuf</SPAN
265
 
> also provides the
266
 
          <TT
267
 
CLASS="FUNCTION"
268
 
>gdk_pixbuf_render_pixmap_and_mask()</TT
269
 
>
270
 
          function; this will create new pixmap and mask drawables for
271
 
          a whole pixbuf and render the image data onto them.  Only
272
 
          trivially simple applications should find a use for this
273
 
          function, since usually you want finer control of how things
274
 
          are rendered.
275
 
        </P
276
 
></DIV
277
 
><BR
278
 
CLEAR="all"><DIV
279
 
CLASS="SECT2"
280
 
><H2
281
 
CLASS="SECT2"
282
 
><A
283
 
NAME="AEN3803">Scaling Images</H2
284
 
><P
285
 
>         <SPAN
286
 
CLASS="APPLICATION"
287
 
>Imlib</SPAN
288
 
> lets you render scaled image data at the time you
289
 
          call <TT
290
 
CLASS="FUNCTION"
291
 
>gdk_imlib_render()</TT
292
 
>.  Again, this
293
 
          unfortunately scales and renders the whole image onto a new
294
 
          pixmap.
295
 
        </P
296
 
><P
297
 
>         <SPAN
298
 
CLASS="APPLICATION"
299
 
>gdk-pixbuf</SPAN
300
 
> provides a number of functions that do scaling
301
 
          of arbitrary regions of a source pixbuf onto a destination
302
 
          one.  These functions can also perform compositing
303
 
          operations against the data in the destination pixbuf or
304
 
          against a solid color or a colored checkerboard.
305
 
          <A
306
 
NAME="AEN3810"
307
 
HREF="#FTN.AEN3810"
308
 
>[1]</A
309
 
>
310
 
        </P
311
 
><P
312
 
>         Very simple applications may find it sufficient to use
313
 
          <TT
314
 
CLASS="FUNCTION"
315
 
>gdk_pixbuf_scale_simple()</TT
316
 
> or
317
 
          <TT
318
 
CLASS="FUNCTION"
319
 
>gdk_pixbuf_composite_color_simple()</TT
320
 
>.
321
 
          These functions scale the whole source image at a time and
322
 
          create a new pixbuf with the result.
323
 
        </P
324
 
><P
325
 
>         More sophisticated applications will need to use
326
 
          <TT
327
 
CLASS="FUNCTION"
328
 
>gdk_pixbuf_scale()</TT
329
 
>,
330
 
          <TT
331
 
CLASS="FUNCTION"
332
 
>gdk_pixbuf_composite()</TT
333
 
>, or
334
 
          <TT
335
 
CLASS="FUNCTION"
336
 
>gdk_pixbuf_composite_color()</TT
337
 
> instead.
338
 
          These functions let you scale and composite an arbitrary
339
 
          region of the source pixbuf onto a destination pixbuf that
340
 
          you provide.
341
 
        </P
342
 
></DIV
343
 
><BR
344
 
CLEAR="all"><DIV
345
 
CLASS="SECT2"
346
 
><H2
347
 
CLASS="SECT2"
348
 
><A
349
 
NAME="AEN3820">Getting Image Data from a Drawable</H2
350
 
><P
351
 
>         <SPAN
352
 
CLASS="APPLICATION"
353
 
>Imlib</SPAN
354
 
> lets you create an image by fetching a drawable's
355
 
          contents from the X server and converting those into RGB
356
 
          data.  This is done with the
357
 
          <TT
358
 
CLASS="FUNCTION"
359
 
>gdk_imlib_create_image_from_drawable()</TT
360
 
>
361
 
          function.
362
 
        </P
363
 
><P
364
 
>         <SPAN
365
 
CLASS="APPLICATION"
366
 
>gdk-pixbuf</SPAN
367
 
> provides the
368
 
          <TT
369
 
CLASS="FUNCTION"
370
 
>gdk_pixbuf_get_from_drawable()</TT
371
 
> function
372
 
          instead.  It lets you specify a destination pixbuf instead
373
 
          of always creating a new one for you.
374
 
        </P
375
 
></DIV
376
 
></DIV
377
 
><H3
378
 
CLASS="FOOTNOTES"
379
 
>Notes</H3
380
 
><TABLE
381
 
BORDER="0"
382
 
CLASS="FOOTNOTES"
383
 
WIDTH="100%"
384
 
><TR
385
 
><TD
386
 
ALIGN="LEFT"
387
 
VALIGN="TOP"
388
 
WIDTH="5%"
389
 
><A
390
 
NAME="FTN.AEN3810"
391
 
HREF="x3767.html#AEN3810"
392
 
>[1]</A
393
 
></TD
394
 
><TD
395
 
ALIGN="LEFT"
396
 
VALIGN="TOP"
397
 
WIDTH="95%"
398
 
><P
399
 
>             You can use a colored checkerboard as the background for
400
 
              compositing when you want to provide a visual indication
401
 
              that the image has partially opaque areas.  This is
402
 
              normally used in image editing and viewing programs.
403
 
            </P
404
 
><P
405
 
>             Compositing against a single solid color is actually a
406
 
              special case of a checkerboard; it simply uses checks of
407
 
              the same color.
408
 
            </P
409
 
></TD
410
 
></TR
411
 
></TABLE
412
 
><DIV
413
 
CLASS="NAVFOOTER"
414
 
><BR
415
 
CLEAR="all"><BR><TABLE
416
 
WIDTH="100%"
417
 
BORDER="0"
418
 
BGCOLOR="#000000"
419
 
CELLPADDING="1"
420
 
CELLSPACING="0"
421
 
><TR
422
 
><TD
423
 
WIDTH="25%"
424
 
BGCOLOR="#C00000"
425
 
ALIGN="left"
426
 
><A
427
 
HREF="x3715.html"
428
 
><FONT
429
 
COLOR="#FFFFFF"
430
 
SIZE="3"
431
 
><B
432
 
>&#60;&#60;&#60; Previous Page</B
433
 
></FONT
434
 
></A
435
 
></TD
436
 
><TD
437
 
WIDTH="25%"
438
 
BGCOLOR="#0000C0"
439
 
ALIGN="center"
440
 
><FONT
441
 
COLOR="#FFFFFF"
442
 
SIZE="3"
443
 
><B
444
 
><A
445
 
HREF="index.html"
446
 
><FONT
447
 
COLOR="#FFFFFF"
448
 
SIZE="3"
449
 
><B
450
 
>Home</B
451
 
></FONT
452
 
></A
453
 
></B
454
 
></FONT
455
 
></TD
456
 
><TD
457
 
WIDTH="25%"
458
 
BGCOLOR="#00C000"
459
 
ALIGN="center"
460
 
><FONT
461
 
COLOR="#FFFFFF"
462
 
SIZE="3"
463
 
><B
464
 
><A
465
 
HREF="a3696.html"
466
 
><FONT
467
 
COLOR="#FFFFFF"
468
 
SIZE="3"
469
 
><B
470
 
>Up</B
471
 
></FONT
472
 
></A
473
 
></B
474
 
></FONT
475
 
></TD
476
 
><TD
477
 
WIDTH="25%"
478
 
BGCOLOR="#C00000"
479
 
ALIGN="right"
480
 
><A
481
 
HREF="compiling.html"
482
 
><FONT
483
 
COLOR="#FFFFFF"
484
 
SIZE="3"
485
 
><B
486
 
>Next Page &#62;&#62;&#62;</B
487
 
></FONT
488
 
></A
489
 
></TD
490
 
></TR
491
 
><TR
492
 
><TD
493
 
COLSPAN="2"
494
 
ALIGN="left"
495
 
><FONT
496
 
COLOR="#FFFFFF"
497
 
SIZE="3"
498
 
><B
499
 
>Differences between <SPAN
500
 
CLASS="APPLICATION"
501
 
>Imlib</SPAN
502
 
> and <SPAN
503
 
CLASS="APPLICATION"
504
 
>gdk-pixbuf</SPAN
505
 
></B
506
 
></FONT
507
 
></TD
508
 
><TD
509
 
COLSPAN="2"
510
 
ALIGN="right"
511
 
><FONT
512
 
COLOR="#FFFFFF"
513
 
SIZE="3"
514
 
><B
515
 
>Compiling the <SPAN
516
 
CLASS="APPLICATION"
517
 
>gdk-pixbuf</SPAN
518
 
> library</B
519
 
></FONT
520
 
></TD
521
 
></TR
522
 
></TABLE
523
 
></DIV
524
 
></BODY
525
 
></HTML
526
 
>
 
 
b'\\ No newline at end of file'