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.
220 Since these functions use GdkRGB for rendering, you must
221 initialize GdkRGB before using any of them. You can do this by
222 calling gdk_rgb_init() near the beginning of your program.
227 <!-- ##### SECTION ./tmpl/rendering.sgml:See_Also ##### -->
233 <!-- ##### SECTION ./tmpl/rendering.sgml:Short_Description ##### -->
234 Rendering a pixbuf to a GDK drawable.
237 <!-- ##### SECTION ./tmpl/rendering.sgml:Title ##### -->
241 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Long_Description ##### -->
243 The functions in this section allow you to take the image data
244 from an X drawable and dump it into a #GdkPixbuf. This can be
245 used for screenshots and other special effects. Note that these
246 operations can be expensive, since the image data has to be
247 transferred from the X server to the client program and converted.
251 These functions are analogous to those for the Gdk version of
256 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:See_Also ##### -->
262 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Short_Description ##### -->
263 Getting parts of an X drawable's image data into a pixbuf.
266 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Title ##### -->
267 X Drawables to Pixbufs
270 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Long_Description ##### -->
272 In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
273 package provides a small library that lets Xlib-only applications
274 use #GdkPixbuf structures and render them to X drawables. The
275 functions in this section are used to initialize the &gdk-pixbuf;
276 Xlib library. This library must be initialized near the beginning
277 or the program or before calling any of the other &gdk-pixbuf;
278 Xlib functions; it cannot be initialized automatically since
279 Xlib-only applications do not call gdk_rgb_init() like GNOME
284 <!-- ##### SECTION ./tmpl/xlib-init.sgml:See_Also ##### -->
290 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Short_Description ##### -->
291 Initializing the &gdk-pixbuf; Xlib library.
294 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Title ##### -->
295 &gdk-pixbuf; Xlib initialization
298 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Long_Description ##### -->
300 The &gdk-pixbuf; Xlib library provides several convenience
301 functions to render pixbufs to X drawables. It uses XlibRGB to
302 render the image data.
306 These functions are analogous to those for the Gdk version of
311 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:See_Also ##### -->
317 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Short_Description ##### -->
318 Rendering a pixbuf to an X drawable.
321 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Title ##### -->
325 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Long_Description ##### -->
327 The XlibRGB set of functions is a port of the GdkRGB library to
328 use plain Xlib and X drawables. You can use these functions to
329 render RGB buffers into drawables very quickly with high-quality
334 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:See_Also ##### -->
340 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Short_Description ##### -->
341 Functions for rendering RGB buffers to X drawables.
344 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Title ##### -->
348 <!-- ##### MACRO GDK_PIXBUF_LOADER ##### -->
350 Casts a #GtkObject to a #GdkPixbufLoader.
355 <!-- ##### MACRO GNOME_CANVAS_PIXBUF ##### -->
357 Casts a #GtkOjbect to a #GnomeCanvasPixbuf.
362 <!-- ##### STRUCT GdkPixbufFrame ##### -->
364 This object describes an individual frame of an animation.
368 <!-- ##### ENUM GdkPixbufFrameAction ##### -->
373 @GDK_PIXBUF_FRAME_RETAIN:
374 @GDK_PIXBUF_FRAME_DISPOSE:
375 @GDK_PIXBUF_FRAME_REVERT:
377 <!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
379 A function of this type can be used to override the default
380 operation when a pixbuf loses its last reference, i.e. when
381 gdk_pixbuf_unref() is called on a #GdkPixbuf structure that has a
382 reference count of 1. This function should determine whether to
383 finalize the pixbuf by calling gdk_pixbuf_finalize(), or whether
384 to just resume normal execution. The last unref handler for a
385 #GdkPixbuf can be set using the
386 gdk_pixbuf_set_last_unref_handler() function. By default, pixbufs
387 will be finalized automatically if no last unref handler has been
391 @pixbuf: The pixbuf that is losing its last reference.
392 @data: User closure data.
394 <!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
396 Indicates the height the pixbuf will be scaled to. This argument
397 will only be used if the <link
398 linkend="GnomeCanvasPixbuf--height-set">height_set</link> argument
399 is %TRUE. Works in the same way as the <link
400 linkend="GnomeCanvasPixbuf--width">width</link> argument.
404 <!-- ##### ARG GnomeCanvasPixbuf:height-in-pixels ##### -->
406 Works in the same way as the <link
407 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
408 argument. The default is %FALSE.
412 <!-- ##### ARG GnomeCanvasPixbuf:height-pixels ##### -->
418 <!-- ##### ARG GnomeCanvasPixbuf:height-set ##### -->
420 Determines whether the <link
421 linkend="GnomeCanvasPixbuf--height">height</link> argument is
422 taken into account when scaling the pixbuf item. Works in the
423 same way as the <link
424 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument.
425 The default is %FALSE.
429 <!-- ##### ARG GnomeCanvasPixbuf:pixbuf ##### -->
431 Contains a pointer to a #GdkPixbuf structure that will be used by
432 the pixbuf canvas item as an image source. When a pixbuf is set
433 its reference count is incremented; if the pixbuf item kept a
434 pointer to another #GdkPixbuf structure, the reference count of
435 this structure will be decremented. Also, the GdkPixbuf's
436 reference count will automatically be decremented when the
437 #GnomeCanvasPixbuf item is destroyed. When a pixbuf is queried, a
438 reference count will not be added to the return value; you must do
439 this yourself if you intend to keep the pixbuf structure around.
443 <!-- ##### ARG GnomeCanvasPixbuf:width ##### -->
445 Indicates the width the pixbuf will be scaled to. This argument
446 will only be used if the <link
447 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument
448 is %TRUE. If the <link
449 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
450 argument is %FALSE, the width will be taken to be in canvas units,
451 and thus will be scaled along with the canvas item's affine
452 transformation. If width_in_pixels is %TRUE, the width will be
453 taken to be in pixels, and will visually remain a constant size
454 even if the item's affine transformation changes.
458 <!-- ##### ARG GnomeCanvasPixbuf:width-in-pixels ##### -->
460 If this argument is %TRUE, then the width of the pixbuf will be
461 considered to be in pixels, that is, it will not be visually
462 scaled even if the item's affine transformation changes. If this
463 is %FALSE, then the width of the pixbuf will be considered to be
464 in canvas units, and so will be scaled normally by affine
465 transformations. The default is %FALSE.
469 <!-- ##### ARG GnomeCanvasPixbuf:width-pixels ##### -->
475 <!-- ##### ARG GnomeCanvasPixbuf:width-set ##### -->
477 Determines whether the <link
478 linkend="GnomeCanvasPixbuf--width">width</link> argument is taken
479 into account when scaling the pixbuf item. If this argument is
480 %FALSE, then the width value of the pixbuf will be used instead.
481 This argument is %FALSE by default.
485 <!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
487 Indicates the horizontal translation offset of the pixbuf item's
488 image. This offset may not actually appear horizontal, since it
489 will be affected by the item's affine transformation. The default
494 <!-- ##### ARG GnomeCanvasPixbuf:x-in-pixels ##### -->
496 If this argument is %TRUE, the pixbuf's translation with respect
497 to its logical origin in item-relative coordinates will be in
498 pixels, that is, the visible offset will not change even if the
499 item's affine transformation changes. If it is %FALSE, the
500 pixbuf's translation will be taken to be in canvas units, and thus
501 will change along with the item's affine transformation. The
506 <!-- ##### ARG GnomeCanvasPixbuf:x-pixels ##### -->
512 <!-- ##### ARG GnomeCanvasPixbuf:x-set ##### -->
514 Determines whether the <link
515 linkend="GnomeCanvasPixbuf--x">x</link> argument is used to
516 translate the pixbuf from its logical origin in item-relative
521 <!-- ##### ARG GnomeCanvasPixbuf:y ##### -->
523 Indicates the vertical translation offset of the pixbuf item's
524 image. Works in the same way as the <link
525 linkend="GnomeCanvasPixbuf--x">x</link> argument. The default is
530 <!-- ##### ARG GnomeCanvasPixbuf:y-in-pixels ##### -->
532 Works in the same way as the <link
533 linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
534 argument, but controls whether the <link
535 linkend="GnomeCanvasPixbuf--y">y</link> translation offset is
536 scaled or not. The default is %FALSE.
542 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
547 <!-- ##### ARG GnomeCanvasPixbuf:y-pixels ##### -->
553 <!-- ##### ARG GnomeCanvasPixbuf:y-set ##### -->
555 Determines whether the <link
556 linkend="GnomeCanvasPixbuf--y">y</link> argument is used to
557 translate the pixbuf from its logical origin in item-relative
558 coordinates. Works in the same way as the <link
559 linkend="GnomeCanvasPixbuf--x-set">x_set</link> argument. The