4
>Converting Applications to gdk-pixbuf</TITLE
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10
TITLE="The gdk-pixbuf Library"
11
HREF="index.html"><LINK
13
TITLE="Porting applications from Imlib to gdk-pixbuf"
14
HREF="a3696.html"><LINK
16
TITLE="Differences between Imlib and gdk-pixbuf"
17
HREF="x3715.html"><LINK
19
TITLE="Compiling the gdk-pixbuf library"
20
HREF="compiling.html"></HEAD
60
><<< Previous Page</B
109
HREF="compiling.html"
114
>Next Page >>></B
127
NAME="AEN3767">Converting Applications to <SPAN
132
> This sections describes the actual changes you need to make in
136
> program to make it use <SPAN
147
NAME="AEN3773">Image loading and creation</H2
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.
158
> To load an image file in a single function call, simply use
161
>gdk_pixbuf_new_from_file()</TT
163
this will make the program block until the whole file has
164
been read. This function effectively replaces
167
>gdk_imlib_load_image()</TT
171
> If you have RGB data in memory, you can use
174
>gdk_pixbuf_new_from_data()</TT
176
pixbuf out of it; this is a replacement for
179
>gdk_imlib_create_image_from_data()</TT
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.
191
> As a convenience, you can use the
194
>gdk_pixbuf_new_from_xpm_data()</TT
196
to create a pixbuf out of inline XPM data that was compiled
197
into your C program. This is a replacement for
200
>gdk_imlib_create_image_from_xpm_data()</TT
204
> After you have created a pixbuf, you can manipulate it in
205
any way you please and then finally call
208
>gdk_pixbuf_unref()</TT
210
with it. This can be thought of as a replacement for
213
>gdk_imlib_destroy_image()</TT
224
NAME="AEN3790">Rendering Images</H2
226
> Applications that use <SPAN
232
>gdk_imlib_render()</TT
233
> to render the whole
234
image data onto a pixmap that <SPAN
238
must copy that pixmap's data into the final destination for
245
> provides convenience functions to
246
render arbitrary rectangular regions of an image onto a
247
drawable that your application provides. You can use
250
>gdk_pixbuf_render_to_drawable()</TT
254
>gdk_pixbuf_render_to_drawable_alpha()</TT
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
262
> As a convenience, <SPAN
268
>gdk_pixbuf_render_pixmap_and_mask()</TT
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
283
NAME="AEN3803">Scaling Images</H2
288
> lets you render scaled image data at the time you
291
>gdk_imlib_render()</TT
293
unfortunately scales and renders the whole image onto a new
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.
312
> Very simple applications may find it sufficient to use
315
>gdk_pixbuf_scale_simple()</TT
319
>gdk_pixbuf_composite_color_simple()</TT
321
These functions scale the whole source image at a time and
322
create a new pixbuf with the result.
325
> More sophisticated applications will need to use
328
>gdk_pixbuf_scale()</TT
332
>gdk_pixbuf_composite()</TT
336
>gdk_pixbuf_composite_color()</TT
338
These functions let you scale and composite an arbitrary
339
region of the source pixbuf onto a destination pixbuf that
349
NAME="AEN3820">Getting Image Data from a Drawable</H2
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
359
>gdk_imlib_create_image_from_drawable()</TT
370
>gdk_pixbuf_get_from_drawable()</TT
372
instead. It lets you specify a destination pixbuf instead
373
of always creating a new one for you.
391
HREF="x3767.html#AEN3810"
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.
405
> Compositing against a single solid color is actually a
406
special case of a checkerboard; it simply uses checks of
415
CLEAR="all"><BR><TABLE
432
><<< Previous Page</B
481
HREF="compiling.html"
486
>Next Page >>></B
499
>Differences between <SPAN
b'\\ No newline at end of file'