1 <!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
3 If this argument is %TRUE, then the width of the pixbuf will be
4 considered to be in pixels, that is, it will not be visually
5 scaled even if the item's affine transformation changes. If this
6 is %FALSE, then the width of the pixbuf will be considered to be
7 in canvas units, and so will be scaled normally by affine
8 transformations. The default is %FALSE.
12 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:See_Also ##### -->
18 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:See_Also ##### -->
20 #GnomeCanvas, #GdkPixbuf
24 <!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:Short_Description ##### -->
28 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Short_Description ##### -->
29 Canvas item to display #GdkPixbuf images.
32 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Long_Description ##### -->
34 The &gdk-pixbuf; Xlib library provides several convenience
35 functions to render pixbufs to X drawables. It uses XlibRGB to
36 render the image data.
40 These functions are analogous to those for the Gdk version of
45 <!-- ##### FUNCTION gdk_pixbuf_render_threshold_alpha ##### -->
60 <!-- ##### SECTION ./tmpl/rendering.sgml:Long_Description ##### -->
62 The &gdk-pixbuf; library provides several convenience functions to
63 render pixbufs to GDK drawables. It uses the GdkRGB to render the
68 At this point there is not a standard alpha channel extension for
69 the X Window System, so it is not possible to use full opacity
70 information when painting images to arbitrary drawables. The
71 &gdk-pixbuf; convenience functions will threshold the opacity
72 information to create a bi-level clipping mask (black and white),
73 and use that to draw the image onto a drawable.
78 Since these functions use GdkRGB for rendering, you must
79 initialize GdkRGB before using any of them. You can do this by
80 calling gdk_rgb_init() near the beginning of your program.
85 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Title ##### -->
86 &gdk-pixbuf; Xlib initialization
89 <!-- ##### ARG GnomeCanvasPixbuf:height_in_pixels ##### -->
91 Works in the same way as the <link
92 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
93 argument. The default is %FALSE.
97 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:See_Also ##### -->
103 <!-- ##### SECTION ./tmpl/rendering.sgml:Title ##### -->
107 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Short_Description ##### -->
108 Getting parts of an X drawable's image data into a pixbuf.
111 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Short_Description ##### -->
112 Getting parts of a drawable's image data into a pixbuf.
115 <!-- ##### FUNCTION gdk_pixbuf_render_pixmap_and_mask ##### -->
123 @alpha_threshold: <!--
126 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
130 <!-- ##### ARG GnomeCanvasPixbuf:y_in_pixels ##### -->
132 Works in the same way as the <link
133 linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
134 argument, but controls whether the <link
135 linkend="GnomeCanvasPixbuf--y">y</link> translation offset is
136 scaled or not. The default is %FALSE.
142 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
147 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Short_Description ##### -->
148 Initializing the &gdk-pixbuf; Xlib library.
151 <!-- ##### FUNCTION gdk_pixbuf_render_to_drawable_alpha ##### -->
170 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Long_Description ##### -->
172 The XlibRGB set of functions is a port of the GdkRGB library to
173 use plain Xlib and X drawables. You can use these functions to
174 render RGB buffers into drawables very quickly with high-quality
179 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Long_Description ##### -->
181 This canvas item displays #GdkPixbuf images. It handles full
182 affine transformations in both GDK and antialiased modes, and also
183 supports the <ulink url="http://www.w3.org">W3C</ulink>'s <ulink
184 url="http://www.w3.org/Graphics/SVG/">SVG</ulink>-like scaling and
185 translation semantics for absolute pixel values.
189 #GdkPixbuf structures may be shared among different pixbuf canvas
190 items; the pixbuf item uses #GdkPixbuf's reference counting
195 <title>Custom Scaling and Translation</title>
198 In addition to the normal affine transformations supported by
199 canvas items, the #GnomeCanvasPixbuf item supports independent
200 object arguments for scaling and translation. This is useful
201 for explicitly setting a size to which the pixbuf's image will
202 be scaled, and for specifying translation offsets that take
203 place in the item's local coordinate system.
207 By default, the pixbuf canvas item will attain the size in units
208 of the #GdkPixbuf it contains. If a #GnomeCanvasPixbuf is
209 configured to use a #GdkPixbuf that has a size of 300 by 200
210 pixels, then the pixbuf item will automatically obtain a size of
211 300 by 200 units in the item's local coordinate system. If the
212 item is transformed with a scaling transformation of (0.5, 2.0),
213 then the final image size will be of 150 by 400 pixels.
217 To set custom width and height values, you must set the <link
218 linkend="GnomeCanvasPixbuf--width-set">width_set</link> or <link
219 linkend="GnomeCanvasPixbuf--height-set">height_set</link>
220 arguments to %TRUE, and then set the <link
221 linkend="GnomeCanvasPixbuf--width">width</link> or <link
222 linkend="GnomeCanvasPixbuf--height">height</link> arguments to
223 the desired values. The former two arguments control whether
224 the latter two are used when computing the final image's size;
225 they are both %FALSE by default so that the pixbuf item will
226 attain a size in units equal to the size in pixels of the
227 #GdkPixbuf that the item contains.
231 The custom translation offsets are controlled by the <link
232 linkend="GnomeCanvasPixbuf--x">x</link> and <link
233 linkend="GnomeCanvasPixbuf--y">y</link> arguments. The logical
234 upper-left vertex of the image will be translated by the
235 specified distance, aligned with the item's local coordinate
241 <title>Absolute Pixel Scaling and Translation</title>
244 The <ulink url="http://www.w3.org/Graphics/SVG/">Scalable Vector
245 Graphics</ulink> specification (SVG) of the <ulink
246 url="http://www.w3.org">World Wide Web Consortium</ulink> also
247 allows images to be translated and scaled by absolute pixel
248 values that are independent of an item's normal affine
253 Normally, the pixbuf item's translation and scaling arguments
254 are interpreted in units, so they will be modified by the item's
255 affine transformation. The <link
256 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>,
258 linkend="GnomeCanvasPixbuf--height-in-pixels">height_in_pixels</link>,
260 linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>, and
262 linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
263 object arguments can be used to modify this behavior. If one of
264 these arguments is %TRUE, then the corresponding scaling or
265 translation value will not be affected lengthwise by the pixbuf
266 item's affine transformation.
270 For example, consider a pixbuf item whose size is (300, 200).
271 If the item is modified with a scaling transformation of (0.5,
273 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
274 is set to %TRUE, then the item will appear to be (300, 400)
275 pixels in size. This means that in this case the item's affine
276 transformation only applies to the height value, while the width
277 value is kept in absolute pixels.
281 Likewise, consider a pixbuf item whose (<link
282 linkend="GnomeCanvasPixbuf--x">x</link>, <link
283 linkend="GnomeCanvasPixbuf--y">y</link>) arguments are set to
284 (30, 40). If the item is then modified by the same scaling
285 transformation of (0.5, 2.0) but the <link
286 linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
287 argument is set to %TRUE, then the image's upper-left corner
288 will appear to be at position (15, 40). In this case, the
289 affine transformation is applied only to the x offset, while the
290 y offset is kept in absolute pixels.
294 In short, these arguments control whether a particular dimension
295 of a pixbuf item is scaled or not in the normal way by the
296 item's affine transformation.
301 <title>Resource Management</title>
304 When you set the #GdkPixbuf structure that a #GnomeCanvasPixbuf
305 item will use by setting the <link
306 linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument, a
307 reference count will be added to that #GdkPixbuf structure.
308 When the pixbuf item no longer needs the #GdkPixbuf structure,
309 such as when the item is destroyed or when a new pixbuf
310 structure is passed to it, then the old #GdkPixbuf structure
311 will be automatically unreferenced.
315 This means that if an application just needs to load a pixbuf
316 image and set it into a pixbuf canvas item, it can do the
317 following to ‘forget’ about the pixbuf structure:
321 GnomeCanvasItem *item;
323 pixbuf = gdk_pixbuf_new_from_file ("foo.png");
324 g_assert (pixbuf != NULL);
326 item = gnome_canvas_item_new (gnome_canvas_root (my_canvas),
327 gnome_canvas_pixbuf_get_type (),
330 gdk_pixbuf_unref (pixbuf);
335 After this happens, the reference count of the pixbuf structure
336 will be 1: the gdk_pixbuf_new_from_file() function creates it
337 with a reference count of 1, then setting the <link
338 linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument of
339 the #GnomeCanvasPixbuf item increases it to 2, and then it is
340 decremented to 1 by the call to gdk_pixbuf_unref(). When the
341 canvas item is destroyed, it will automatically unreference the
342 pixbuf structure again, causing its reference count to drop to
343 zero and thus be freed.
348 <!-- ##### SECTION ./tmpl/rendering.sgml:Short_Description ##### -->
349 Rendering a pixbuf to a GDK drawable.
352 <!-- ##### MACRO GDK_PIXBUF_LOADER ##### -->
354 Casts a #GtkObject to a #GdkPixbufLoader.
359 <!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
365 <!-- ##### ARG GnomeCanvasPixbuf:x_set ##### -->
367 Determines whether the <link
368 linkend="GnomeCanvasPixbuf--x">x</link> argument is used to
369 translate the pixbuf from its logical origin in item-relative
374 <!-- ##### MACRO GNOME_CANVAS_PIXBUF ##### -->
376 Casts a #GtkOjbect to a #GnomeCanvasPixbuf.
381 <!-- ##### ARG GnomeCanvasPixbuf:width_set ##### -->
383 Determines whether the <link
384 linkend="GnomeCanvasPixbuf--width">width</link> argument is taken
385 into account when scaling the pixbuf item. If this argument is
386 %FALSE, then the width value of the pixbuf will be used instead.
387 This argument is %FALSE by default.
391 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Long_Description ##### -->
393 The functions in this section allow you to take the image data
394 from an X drawable and dump it into a #GdkPixbuf. This can be
395 used for screenshots and other special effects. Note that these
396 operations can be expensive, since the image data has to be
397 transferred from the X server to the client program and converted.
401 These functions are analogous to those for the Gdk version of
406 <!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
408 A function of this type can be used to override the default
409 operation when a pixbuf loses its last reference, i.e. when
410 gdk_pixbuf_unref() is called on a #GdkPixbuf structure that has a
411 reference count of 1. This function should determine whether to
412 finalize the pixbuf by calling gdk_pixbuf_finalize(), or whether
413 to just resume normal execution. The last unref handler for a
414 #GdkPixbuf can be set using the
415 gdk_pixbuf_set_last_unref_handler() function. By default, pixbufs
416 will be finalized automatically if no last unref handler has been
420 @pixbuf: The pixbuf that is losing its last reference.
421 @data: User closure data.
423 <!-- ##### SECTION ./tmpl/xlib-init.sgml:See_Also ##### -->
429 <!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:See_Also ##### -->
435 <!-- ##### FUNCTION gdk_pixbuf_new_from_art_pixbuf ##### -->
443 <!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
445 Indicates the height the pixbuf will be scaled to. This argument
446 will only be used if the <link
447 linkend="GnomeCanvasPixbuf--height-set">height_set</link> argument
448 is %TRUE. Works in the same way as the <link
449 linkend="GnomeCanvasPixbuf--width">width</link> argument.
453 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Title ##### -->
457 <!-- ##### SECTION ./tmpl/from-drawables.sgml:See_Also ##### -->
463 <!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
469 <!-- ##### ARG GnomeCanvasPixbuf:pixbuf ##### -->
471 Contains a pointer to a #GdkPixbuf structure that will be used by
472 the pixbuf canvas item as an image source. When a pixbuf is set
473 its reference count is incremented; if the pixbuf item kept a
474 pointer to another #GdkPixbuf structure, the reference count of
475 this structure will be decremented. Also, the GdkPixbuf's
476 reference count will automatically be decremented when the
477 #GnomeCanvasPixbuf item is destroyed. When a pixbuf is queried, a
478 reference count will not be added to the return value; you must do
479 this yourself if you intend to keep the pixbuf structure around.
483 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Short_Description ##### -->
484 Functions for rendering RGB buffers to X drawables.
487 <!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
489 Indicates the horizontal translation offset of the pixbuf item's
490 image. This offset may not actually appear horizontal, since it
491 will be affected by the item's affine transformation. The default
496 <!-- ##### ARG GnomeCanvasPixbuf:y ##### -->
498 Indicates the vertical translation offset of the pixbuf item's
499 image. Works in the same way as the <link
500 linkend="GnomeCanvasPixbuf--x">x</link> argument. The default is
505 <!-- ##### ARG GnomeCanvasPixbuf:width ##### -->
507 Indicates the width the pixbuf will be scaled to. This argument
508 will only be used if the <link
509 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument
510 is %TRUE. If the <link
511 linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
512 argument is %FALSE, the width will be taken to be in canvas units,
513 and thus will be scaled along with the canvas item's affine
514 transformation. If width_in_pixels is %TRUE, the width will be
515 taken to be in pixels, and will visually remain a constant size
516 even if the item's affine transformation changes.
520 <!-- ##### FUNCTION gdk_pixbuf_set_last_unref_handler ##### -->
529 <!-- ##### ARG GnomeCanvasPixbuf:height_set ##### -->
531 Determines whether the <link
532 linkend="GnomeCanvasPixbuf--height">height</link> argument is
533 taken into account when scaling the pixbuf item. Works in the
534 same way as the <link
535 linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument.
536 The default is %FALSE.
540 <!-- ##### FUNCTION gdk_pixbuf_render_to_drawable ##### -->
558 <!-- ##### SECTION ./tmpl/xlib-init.sgml:Long_Description ##### -->
560 In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
561 package provides a small library that lets Xlib-only applications
562 use #GdkPixbuf structures and render them to X drawables. The
563 functions in this section are used to initialize the &gdk-pixbuf;
564 Xlib library. This library must be initialized near the beginning
565 or the program or before calling any of the other &gdk-pixbuf;
566 Xlib functions; it cannot be initialized automatically since
567 Xlib-only applications do not call gdk_rgb_init() like GNOME
572 <!-- ##### ARG GnomeCanvasPixbuf:y_pixels ##### -->
578 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:See_Also ##### -->
584 <!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:Long_Description ##### -->
590 <!-- ##### SECTION ./tmpl/rendering.sgml:See_Also ##### -->
596 <!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Short_Description ##### -->
597 Rendering a pixbuf to an X drawable.
600 <!-- ##### FUNCTION gdk_pixbuf_finalize ##### -->
608 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
612 <!-- ##### FUNCTION gdk_pixbuf_get_from_drawable ##### -->
629 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
633 <!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:Title ##### -->
637 <!-- ##### ARG GnomeCanvasPixbuf:y_set ##### -->
639 Determines whether the <link
640 linkend="GnomeCanvasPixbuf--y">y</link> argument is used to
641 translate the pixbuf from its logical origin in item-relative
642 coordinates. Works in the same way as the <link
643 linkend="GnomeCanvasPixbuf--x-set">x_set</link> argument. The
648 <!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Title ##### -->
652 <!-- ##### ARG GnomeCanvasPixbuf:x_pixels ##### -->
658 <!-- ##### FUNCTION gdk_pixbuf_get_format ##### -->
666 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Long_Description ##### -->
668 The functions in this section allow you to take the image data
669 from a GDK drawable and dump it into a #GdkPixbuf. This can be
670 used for screenshots and other special effects. Note that these
671 operations can be expensive, since the image data has to be
672 transferred from the X server to the client program and converted.
676 <!-- ##### ARG GnomeCanvasPixbuf:width_pixels ##### -->
682 <!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Title ##### -->
683 X Drawables to Pixbufs
686 <!-- ##### STRUCT GdkPixbufClass ##### -->
692 <!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
696 <!-- ##### ARG GnomeCanvasPixbuf:x_in_pixels ##### -->
698 If this argument is %TRUE, the pixbuf's translation with respect
699 to its logical origin in item-relative coordinates will be in
700 pixels, that is, the visible offset will not change even if the
701 item's affine transformation changes. If it is %FALSE, the
702 pixbuf's translation will be taken to be in canvas units, and thus
703 will change along with the item's affine transformation. The
708 <!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Title ##### -->