1 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Long_Description ##### -->
3 The functions in this section allow you to take the image data
4 from a GDK drawable and dump it into a #GdkPixbuf. This can be
5 used for screenshots and other special effects. Note that these
6 operations can be expensive, since the image data has to be
7 transferred from the X server to the client program and converted.
11 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Short_Description ##### -->
12 Getting parts of a drawable's image data into a pixbuf.
15 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
19 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Long_Description ##### -->
21 This canvas item displays #GdkPixbuf images. It handles full
22 affine transformations in both GDK and antialiased modes, and also
23 supports the <ulink url="http://www.w3.org">W3C</ulink>'s <ulink
24 url="http://www.w3.org/Graphics/SVG/">SVG</ulink>-like scaling and
25 translation semantics for absolute pixel values.
29 #GdkPixbuf structures may be shared among different pixbuf canvas
30 items; the pixbuf item uses #GdkPixbuf's reference counting
35 <title>Custom Scaling and Translation</title>
38 In addition to the normal affine transformations supported by
39 canvas items, the #GnomeCanvasPixbuf item supports independent
40 object arguments for scaling and translation. This is useful
41 for explicitly setting a size to which the pixbuf's image will
42 be scaled, and for specifying translation offsets that take
43 place in the item's local coordinate system.
47 By default, the pixbuf canvas item will attain the size in units
48 of the #GdkPixbuf it contains. If a #GnomeCanvasPixbuf is
49 configured to use a #GdkPixbuf that has a size of 300 by 200
50 pixels, then the pixbuf item will automatically obtain a size of
51 300 by 200 units in the item's local coordinate system. If the
52 item is transformed with a scaling transformation of (0.5, 2.0),
53 then the final image size will be of 150 by 400 pixels.
57 To set custom width and height values, you must set the <link
58 linkend="GnomeCanvasPixbuf--width-set">width_set</link> or <link
59 linkend="GnomeCanvasPixbuf--height-set">height_set</link>
60 arguments to %TRUE, and then set the <link
61 linkend="GnomeCanvasPixbuf--width">width</link> or <link
62 linkend="GnomeCanvasPixbuf--height">height</link> arguments to
63 the desired values. The former two arguments control whether
64 the latter two are used when computing the final image's size;
65 they are both %FALSE by default so that the pixbuf item will
66 attain a size in units equal to the size in pixels of the
67 #GdkPixbuf that the item contains.
71 The custom translation offsets are controlled by the <link
72 linkend="GnomeCanvasPixbuf--x">x</link> and <link
73 linkend="GnomeCanvasPixbuf--y">y</link> arguments. The logical
74 upper-left vertex of the image will be translated by the
75 specified distance, aligned with the item's local coordinate
81 <title>Absolute Pixel Scaling and Translation</title>
84 The <ulink url="http://www.w3.org/Graphics/SVG/">Scalable Vector
85 Graphics</ulink> specification (SVG) of the <ulink
86 url="http://www.w3.org">World Wide Web Consortium</ulink> also
87 allows images to be translated and scaled by absolute pixel
88 values that are independent of an item's normal affine
93 Normally, the pixbuf item's translation and scaling arguments
94 are interpreted in units, so they will be modified by the item's
95 affine transformation. The <link
96 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>,
98 linkend="GnomeCanvasPixbuf--height-in-pixels">height_in_pixels</link>,
100 linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>, and
102 linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
103 object arguments can be used to modify this behavior. If one of
104 these arguments is %TRUE, then the corresponding scaling or
105 translation value will not be affected lengthwise by the pixbuf
106 item's affine transformation.
110 For example, consider a pixbuf item whose size is (300, 200).
111 If the item is modified with a scaling transformation of (0.5,
113 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
114 is set to %TRUE, then the item will appear to be (300, 400)
115 pixels in size. This means that in this case the item's affine
116 transformation only applies to the height value, while the width
117 value is kept in absolute pixels.
121 Likewise, consider a pixbuf item whose (<link
122 linkend="GnomeCanvasPixbuf--x">x</link>, <link
123 linkend="GnomeCanvasPixbuf--y">y</link>) arguments are set to
124 (30, 40). If the item is then modified by the same scaling
125 transformation of (0.5, 2.0) but the <link
126 linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
127 argument is set to %TRUE, then the image's upper-left corner
128 will appear to be at position (15, 40). In this case, the
129 affine transformation is applied only to the x offset, while the
130 y offset is kept in absolute pixels.
134 In short, these arguments control whether a particular dimension
135 of a pixbuf item is scaled or not in the normal way by the
136 item's affine transformation.
141 <title>Resource Management</title>
144 When you set the #GdkPixbuf structure that a #GnomeCanvasPixbuf
145 item will use by setting the <link
146 linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument, a
147 reference count will be added to that #GdkPixbuf structure.
148 When the pixbuf item no longer needs the #GdkPixbuf structure,
149 such as when the item is destroyed or when a new pixbuf
150 structure is passed to it, then the old #GdkPixbuf structure
151 will be automatically unreferenced.
155 This means that if an application just needs to load a pixbuf
156 image and set it into a pixbuf canvas item, it can do the
157 following to ‘forget’ about the pixbuf structure:
161 GnomeCanvasItem *item;
163 pixbuf = gdk_pixbuf_new_from_file ("foo.png");
164 g_assert (pixbuf != NULL);
166 item = gnome_canvas_item_new (gnome_canvas_root (my_canvas),
167 gnome_canvas_pixbuf_get_type (),
170 gdk_pixbuf_unref (pixbuf);
175 After this happens, the reference count of the pixbuf structure
176 will be 1: the gdk_pixbuf_new_from_file() function creates it
177 with a reference count of 1, then setting the <link
178 linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument of
179 the #GnomeCanvasPixbuf item increases it to 2, and then it is
180 decremented to 1 by the call to gdk_pixbuf_unref(). When the
181 canvas item is destroyed, it will automatically unreference the
182 pixbuf structure again, causing its reference count to drop to
183 zero and thus be freed.
188 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:See_Also ##### -->
190 #GnomeCanvas, #GdkPixbuf
194 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Short_Description ##### -->
195 Canvas item to display #GdkPixbuf images.
198 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Title ##### -->
202 <!-- ##### SECTION ./tmpl/rendering.sgml:Long_Description ##### -->
204 The &gdk-pixbuf; library provides several convenience functions to
205 render pixbufs to GDK drawables. It uses the GdkRGB to render the
210 At this point there is not a standard alpha channel extension for
211 the X Window System, so it is not possible to use full opacity
212 information when painting images to arbitrary drawables. The
213 &gdk-pixbuf; convenience functions will threshold the opacity
214 information to create a bi-level clipping mask (black and white),
215 and use that to draw the image onto a drawable.
219 <!-- ##### SECTION ./tmpl/rendering.sgml:See_Also ##### -->
225 <!-- ##### SECTION ./tmpl/rendering.sgml:Short_Description ##### -->
226 Rendering a pixbuf to a GDK drawable.
229 <!-- ##### SECTION ./tmpl/rendering.sgml:Title ##### -->
233 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Long_Description ##### -->
235 The functions in this section allow you to take the image data
236 from an X drawable and dump it into a #GdkPixbuf. This can be
237 used for screenshots and other special effects. Note that these
238 operations can be expensive, since the image data has to be
239 transferred from the X server to the client program and converted.
243 These functions are analogous to those for the Gdk version of
248 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:See_Also ##### -->
254 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Short_Description ##### -->
255 Getting parts of an X drawable's image data into a pixbuf.
258 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Title ##### -->
259 X Drawables to Pixbufs
262 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Long_Description ##### -->
264 In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
265 package provides a small library that lets Xlib-only applications
266 use #GdkPixbuf structures and render them to X drawables. The
267 functions in this section are used to initialize the &gdk-pixbuf;
268 Xlib library. This library must be initialized near the beginning
269 or the program or before calling any of the other &gdk-pixbuf;
270 Xlib functions; it cannot be initialized automatically since
271 Xlib-only applications do not call gdk_rgb_init() like GNOME
276 <!-- ##### SECTION ./tmpl/xlib-init.sgml:See_Also ##### -->
282 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Short_Description ##### -->
283 Initializing the &gdk-pixbuf; Xlib library.
286 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Title ##### -->
287 &gdk-pixbuf; Xlib initialization
290 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Long_Description ##### -->
292 The &gdk-pixbuf; Xlib library provides several convenience
293 functions to render pixbufs to X drawables. It uses XlibRGB to
294 render the image data.
298 These functions are analogous to those for the Gdk version of
303 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:See_Also ##### -->
309 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Short_Description ##### -->
310 Rendering a pixbuf to an X drawable.
313 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Title ##### -->
317 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Long_Description ##### -->
319 The XlibRGB set of functions is a port of the GdkRGB library to
320 use plain Xlib and X drawables. You can use these functions to
321 render RGB buffers into drawables very quickly with high-quality
326 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:See_Also ##### -->
332 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Short_Description ##### -->
333 Functions for rendering RGB buffers to X drawables.
336 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Title ##### -->
340 <!-- ##### MACRO GDK_PIXBUF_LOADER ##### -->
342 Casts a #GtkObject to a #GdkPixbufLoader.
347 <!-- ##### MACRO GNOME_CANVAS_PIXBUF ##### -->
349 Casts a #GtkOjbect to a #GnomeCanvasPixbuf.
354 <!-- ##### STRUCT GdkPixbufFrame ##### -->
356 This object describes an individual frame of an animation.
360 <!-- ##### ENUM GdkPixbufFrameAction ##### -->
365 @GDK_PIXBUF_FRAME_RETAIN:
366 @GDK_PIXBUF_FRAME_DISPOSE:
367 @GDK_PIXBUF_FRAME_REVERT:
369 <!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
371 A function of this type can be used to override the default
372 operation when a pixbuf loses its last reference, i.e. when
373 gdk_pixbuf_unref() is called on a #GdkPixbuf structure that has a
374 reference count of 1. This function should determine whether to
375 finalize the pixbuf by calling gdk_pixbuf_finalize(), or whether
376 to just resume normal execution. The last unref handler for a
377 #GdkPixbuf can be set using the
378 gdk_pixbuf_set_last_unref_handler() function. By default, pixbufs
379 will be finalized automatically if no last unref handler has been
383 @pixbuf: The pixbuf that is losing its last reference.
384 @data: User closure data.
386 <!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
388 Indicates the height the pixbuf will be scaled to. This argument
389 will only be used if the <link
390 linkend="GnomeCanvasPixbuf--height-set">height_set</link> argument
391 is %TRUE. Works in the same way as the <link
392 linkend="GnomeCanvasPixbuf--width">width</link> argument.
396 <!-- ##### ARG GnomeCanvasPixbuf:height-in-pixels ##### -->
398 Works in the same way as the <link
399 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
400 argument. The default is %FALSE.
404 <!-- ##### ARG GnomeCanvasPixbuf:height-pixels ##### -->
410 <!-- ##### ARG GnomeCanvasPixbuf:height-set ##### -->
412 Determines whether the <link
413 linkend="GnomeCanvasPixbuf--height">height</link> argument is
414 taken into account when scaling the pixbuf item. Works in the
415 same way as the <link
416 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument.
417 The default is %FALSE.
421 <!-- ##### ARG GnomeCanvasPixbuf:pixbuf ##### -->
423 Contains a pointer to a #GdkPixbuf structure that will be used by
424 the pixbuf canvas item as an image source. When a pixbuf is set
425 its reference count is incremented; if the pixbuf item kept a
426 pointer to another #GdkPixbuf structure, the reference count of
427 this structure will be decremented. Also, the GdkPixbuf's
428 reference count will automatically be decremented when the
429 #GnomeCanvasPixbuf item is destroyed. When a pixbuf is queried, a
430 reference count will not be added to the return value; you must do
431 this yourself if you intend to keep the pixbuf structure around.
435 <!-- ##### ARG GnomeCanvasPixbuf:width ##### -->
437 Indicates the width the pixbuf will be scaled to. This argument
438 will only be used if the <link
439 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument
440 is %TRUE. If the <link
441 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
442 argument is %FALSE, the width will be taken to be in canvas units,
443 and thus will be scaled along with the canvas item's affine
444 transformation. If width_in_pixels is %TRUE, the width will be
445 taken to be in pixels, and will visually remain a constant size
446 even if the item's affine transformation changes.
450 <!-- ##### ARG GnomeCanvasPixbuf:width-in-pixels ##### -->
452 If this argument is %TRUE, then the width of the pixbuf will be
453 considered to be in pixels, that is, it will not be visually
454 scaled even if the item's affine transformation changes. If this
455 is %FALSE, then the width of the pixbuf will be considered to be
456 in canvas units, and so will be scaled normally by affine
457 transformations. The default is %FALSE.
461 <!-- ##### ARG GnomeCanvasPixbuf:width-pixels ##### -->
467 <!-- ##### ARG GnomeCanvasPixbuf:width-set ##### -->
469 Determines whether the <link
470 linkend="GnomeCanvasPixbuf--width">width</link> argument is taken
471 into account when scaling the pixbuf item. If this argument is
472 %FALSE, then the width value of the pixbuf will be used instead.
473 This argument is %FALSE by default.
477 <!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
479 Indicates the horizontal translation offset of the pixbuf item's
480 image. This offset may not actually appear horizontal, since it
481 will be affected by the item's affine transformation. The default
486 <!-- ##### ARG GnomeCanvasPixbuf:x-in-pixels ##### -->
488 If this argument is %TRUE, the pixbuf's translation with respect
489 to its logical origin in item-relative coordinates will be in
490 pixels, that is, the visible offset will not change even if the
491 item's affine transformation changes. If it is %FALSE, the
492 pixbuf's translation will be taken to be in canvas units, and thus
493 will change along with the item's affine transformation. The
498 <!-- ##### ARG GnomeCanvasPixbuf:x-pixels ##### -->
504 <!-- ##### ARG GnomeCanvasPixbuf:x-set ##### -->
506 Determines whether the <link
507 linkend="GnomeCanvasPixbuf--x">x</link> argument is used to
508 translate the pixbuf from its logical origin in item-relative
513 <!-- ##### ARG GnomeCanvasPixbuf:y ##### -->
515 Indicates the vertical translation offset of the pixbuf item's
516 image. Works in the same way as the <link
517 linkend="GnomeCanvasPixbuf--x">x</link> argument. The default is
522 <!-- ##### ARG GnomeCanvasPixbuf:y-in-pixels ##### -->
524 Works in the same way as the <link
525 linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
526 argument, but controls whether the <link
527 linkend="GnomeCanvasPixbuf--y">y</link> translation offset is
528 scaled or not. The default is %FALSE.
534 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
539 <!-- ##### ARG GnomeCanvasPixbuf:y-pixels ##### -->
545 <!-- ##### ARG GnomeCanvasPixbuf:y-set ##### -->
547 Determines whether the <link
548 linkend="GnomeCanvasPixbuf--y">y</link> argument is used to
549 translate the pixbuf from its logical origin in item-relative
550 coordinates. Works in the same way as the <link
551 linkend="GnomeCanvasPixbuf--x-set">x_set</link> argument. The
556 <!-- ##### FUNCTION gdk_pixbuf_animation_ref ##### -->
564 <!-- ##### FUNCTION gdk_pixbuf_animation_unref ##### -->
571 <!-- ##### FUNCTION gdk_pixbuf_ref ##### -->
579 <!-- ##### FUNCTION gdk_pixbuf_unref ##### -->