Package: gdk-pixbuf

Class gdk-pixbuf-loader

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

None

Details

The gdk-pixbuf-loader class provides a way for applications to drive the process of loading an image, by letting them send the image data directly to the loader instead of having the loader read the data from a file. Applications can use this functionality instead of the functions gdk-pixbuf-new-from-file or gdk-pixbuf-animation-new-from-file when they need to parse image data in small chunks. For example, it should be used when reading an image from a (potentially) slow network connection, or when loading an extremely large file.

To use the gdk-pixbuf-loader class to load an image, just create a new one, and call the function gdk-pixbuf-loader-write to send the data to it. When done, the function gdk-pixbuf-loader-close should be called to end the stream and finalize everything. The loader will emit three important signals throughout the process. The first, "size-prepared", will be called as soon as the image has enough information to determine the size of the image to be used. If you want to scale the image while loading it, you can call the function gdk-pixbuf-loader-set-size in response to this signal.

The second signal, "area-prepared", will be called as soon as the pixbuf of the desired has been allocated. You can obtain it by calling the function gdk-pixbuf-loader-pixbuf. In addition, no actual information will be passed in yet, so the pixbuf can be safely filled with any temporary graphics (or an initial color) as needed. You can also call the function gdk-pixbuf-loader-pixbuf later and get the same pixbuf.

The last signal, "area-updated" gets called every time a region is updated. This way you can update a partially completed image. Note that you do not know anything about the completeness of an image from the area updated. For example, in an interlaced image, you need to make several passes before the image is done loading.

Loading an animation
Loading an animation is almost as easy as loading an image. Once the first "area-prepared" signal has been emitted, you can call the function gdk-pixbuf-loader-get-animation to get the gdk-pixbuf-animation object and the function gdk-pixbuf-animation-get-iter to get an gdk-pixbuf-animation-iter structure for displaying it.

Signal Details

The "area-prepared" signal
 lambda (loader)    :run-last      
The signal is emitted when the pixbuf loader has allocated the pixbuf in the desired size. After this signal is emitted, applications can call the gdk-pixbuf-loader-pixbuf function to fetch the partially-loaded pixbuf.
loader
The gdk-pixbuf-loader object which received the signal.
The "area-updated" signal
  lambda (loader x y width height)    :run-last      
The signal is emitted when a significant area of the image being loaded has been updated. Normally it means that a complete scanline has been read in, but it could be a different area as well. Applications can use this signal to know when to repaint areas of an image that is being loaded.
loader
The gdk-pixbuf-loader object which received the signal.
x
An integer with the x offset of upper-left corner of the updated area.
y
An integer with the y offset of upper-left corner of the updated area.
width
An integer with the width of updated area.
height
An integer with the height of updated area.
The "closed" signal
   lambda (loader)    :run-last      
The signal is emitted when the gdk-pixbuf-loader-close function is called. It can be used by different parts of an application to receive notification when an image loader is closed by the code that drives it.
loader
The gdk-pixbuf-loader object which received the signal.
The "size-prepared" signal
 lambda (loader width height)    :run-last      
The signal is emitted when the pixbuf loader has been fed the initial amount of data that is required to figure out the size of the image that it will create. Applications can call the gdk-pixbuf-loader-set-size function in response to this signal to set the desired size to which the image should be scaled.
loader
The gdk-pixbuf-loader object which received the signal.
width
An integer with the original width of the image.
height
An integer with the original height of the image.
 

Inherited Slot Access Functions

See also

2020-11-22