![]() | ![]() | ![]() | The gdk-pixbuf Library | ![]() |
---|
Animations — Animated images.
#include <gdk-pixbuf/gdk-pixbuf.h> struct GdkPixbufAnimation; struct GdkPixbufAnimationIter; GdkPixbufAnimation* gdk_pixbuf_animation_new_from_file (const char *filename,GError **error); GdkPixbufAnimation* gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation); void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation); int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation); int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation); GdkPixbufAnimationIter* gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation, constGTimeVal *start_time);gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation); GdkPixbuf* gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter, constGTimeVal *current_time); int gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter);gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter); GdkPixbuf* gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
GObject +----GdkPixbufAnimation
GObject +----GdkPixbufAnimationIter
The gdk-pixbuf library provides a simple mechanism to load and represent animations. An animation is conceptually a series of frames to be displayed over time. Each frame is the same size. The animation may not be represented as a series of frames internally; for example, it may be stored as a sprite and instructions for moving the sprite around a background. To display an animation you don't need to understand its representation, however; you just ask gdk-pixbuf what should be displayed at a given point in time.
struct GdkPixbufAnimationIter;
A GdkPixbufAnimationIter provides the necessary functionality to display an animation. See gdk_pixbuf_animation_get_iter().
GdkPixbufAnimation* gdk_pixbuf_animation_new_from_file (const char *filename,GError **error);
Creates a new animation by loading it from a file. The file format is
detected automatically. If the file's format does not support multi-frame
images, then an animation with a single frame will be created. Possible errors
are in the GDK_PIXBUF_ERROR and
filename : | Name of file to load. |
error : | return location for error |
Returns : | A newly-created animation with a reference count of 1, or NULL if any of several error conditions ocurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data. |
GdkPixbufAnimation* gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
gdk_pixbuf_animation_ref is deprecated and should not be used in newly-written code. Use
Adds a reference to an animation.
animation : | An animation. |
Returns : | The same as the animation argument. |
void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
gdk_pixbuf_animation_unref is deprecated and should not be used in newly-written code. Use
Removes a reference from an animation.
animation : | An animation. |
int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation);
Queries the width of the bounding box of a pixbuf animation.
animation : | An animation. |
Returns : | Width of the bounding box of the animation. |
int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation);
Queries the height of the bounding box of a pixbuf animation.
animation : | An animation. |
Returns : | Height of the bounding box of the animation. |
GdkPixbufAnimationIter* gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation, constGTimeVal *start_time);
Get an iterator for displaying an animation. The iterator provides
the frames that should be displayed at a given time.
It should be freed after use with
start_time would normally come from
As a shortcut, if start_time is NULL, the result of
To update the image (i.e. possibly change the result of gdk_pixbuf_animation_iter_get_pixbuf() to a new frame of the animation), call gdk_pixbuf_animation_iter_advance().
If you're using GdkPixbufLoader, in addition to updating the image after the delay time, you should also update it whenever you receive the area_updated signal and gdk_pixbuf_animation_iter_on_currently_loading_frame() returns TRUE. In this case, the frame currently being fed into the loader has received new data, so needs to be refreshed. The delay time for a frame may also be modified after an area_updated signal, for example if the delay time for a frame is encoded in the data after the frame itself. So your timeout should be reinstalled after any area_updated signal.
A delay time of -1 is possible, indicating "infinite."
animation : | a GdkPixbufAnimation |
start_time : | time when the animation starts playing |
Returns : | an iterator to move over the animation |
gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation);
If you load a file with gdk_pixbuf_animation_new_from_file() and it turns out to be a plain, unanimated image, then this function will return TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve the image.
animation : | a GdkPixbufAnimation |
Returns : | TRUE if the "animation" was really just an image |
GdkPixbuf* gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
If an animation is really just a plain image (has only one frame), this function returns that image. If the animation is an animation, this function returns a reasonable thing to display as a static unanimated image, which might be the first frame, or something more sophisticated. If an animation hasn't loaded any frames yet, this function will return NULL.
animation : | a GdkPixbufAnimation |
Returns : | unanimated image representing the animation |
gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter, constGTimeVal *current_time);
Possibly advances an animation to a new frame. Chooses the frame based on the start time passed to gdk_pixbuf_animation_get_iter().
current_time would normally come from
As a shortcut, pass NULL for the current time and
If this function returns FALSE, there's no need to update the animation
display, assuming the display had been rendered prior to advancing;
if TRUE, you need to call
iter : | a GdkPixbufAnimationIter |
current_time : | current time |
Returns : | TRUE if the image may need updating |
int gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter);
Gets the number of milliseconds the current pixbuf should be displayed,
or -1 if the current pixbuf should be displayed forever.
iter : | an animation iterator |
Returns : | delay time in milliseconds (thousandths of a second) |
gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
Used to determine how to respond to the area_updated signal on GdkPixbufLoader when loading an animation. area_updated is emitted for an area of the frame currently streaming in to the loader. So if you're on the currently loading frame, you need to redraw the screen for the updated area.
iter : | a GdkPixbufAnimationIter |
Returns : | TRUE if the frame we're on is partially loaded, or the last frame |
GdkPixbuf* gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
Gets the current pixbuf which should be displayed; the pixbuf will
be the same size as the animation itself
(gdk_pixbuf_animation_get_width(),
gdk_pixbuf_animation_get_height()). This pixbuf should be displayed
for
iter : | an animation iterator |
Returns : | the pixbuf to be displayed |
<< Utilities | GdkPixbufLoader >> |