Animations

Name

Animations -- Animations as multi-frame structures.

Synopsis


#include <gdk-pixbuf/gdk-pixbuf.h>


enum        GdkPixbufFrameAction;
struct      GdkPixbufFrame;
struct      GdkPixbufAnimation;
GdkPixbufAnimation* gdk_pixbuf_animation_new_from_file
                                            (const char *filename);
GdkPixbufAnimation* gdk_pixbuf_animation_ref
                                            (GdkPixbufAnimation *animation);
void        gdk_pixbuf_animation_unref      (GdkPixbufAnimation *animation);

Description

The GdkPixbuf library provides a simple mechanism to load and represent animations, primarily animated GIF files. Animations are represented as lists of GdkPixbufFrame structures. Each frame structure contains a GdkPixbuf structure and information about the frame's overlay mode and duration.

Details

enum GdkPixbufFrameAction

typedef enum {
	GDK_PIXBUF_FRAME_RETAIN,
	GDK_PIXBUF_FRAME_DISPOSE,
	GDK_PIXBUF_FRAME_REVERT
} GdkPixbufFrameAction;

Each animation frame can have several things happen to it when the next frame is displayed. The GdkPixbufFrameAction determines this. If a frame as marked as GDK_PIXBUF_FRAME_RETAIN, then the image will remain displayed, and will be potentially occluded by the next frame. If it is marked as GDK_PIXBUF_FRAME_DISPOSE, then the animation is reverted to the setting before the frame was shown. If it is marked as GDK_PIXBUF_FRAME_REVERT, then the animation is reverted to the first image before continuing.


struct GdkPixbufFrame

struct GdkPixbufFrame {
	/* The pixbuf with this frame's image data */
	GdkPixbuf *pixbuf;

	/* Offsets for overlaying onto the animation's area */
	int x_offset;
	int y_offset;

	/* Frame duration in ms */
	int delay_time;

	/* Overlay mode */
	GdkPixbufFrameAction action;
};

This structure describes a frame in a GdkPixbufAnimation. Each frame consists of a GdkPixbuf, an offset of the frame within the animation's bounding box, a duration, and an overlay mode or action.

GdkPixbuf *pixbufThe frame's image contents.
int x_offsetX offset of the frame inside the animation's bounding box.
int y_offsetY offset of the frame inside the animation's bounding box.
int delay_timeDuration of the frame in milliseconds.
GdkPixbufFrameAction actionOverlay mode.


struct GdkPixbufAnimation

struct GdkPixbufAnimation {
	/* Reference count */
	int ref_count;

	/* Number of frames */
        int n_frames;

	/* List of GdkPixbufFrame structures */
        GList *frames;
};

This structure describes an animation, which is represented as a list of GdkPixbufFrame structures.

int ref_countReference count.
int n_framesNumber of frames in the animation.
GList *framesList of GdkPixbufFrame structures.


gdk_pixbuf_animation_new_from_file ()

GdkPixbufAnimation* gdk_pixbuf_animation_new_from_file
                                            (const char *filename);

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.

filename : Name of file to load.
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.


gdk_pixbuf_animation_ref ()

GdkPixbufAnimation* gdk_pixbuf_animation_ref
                                            (GdkPixbufAnimation *animation);

Adds a reference to an animation. It must be released afterwards using gdk_pixbuf_animation_unref().

animation : An animation.
Returns : The same as the animation argument.


gdk_pixbuf_animation_unref ()

void        gdk_pixbuf_animation_unref      (GdkPixbufAnimation *animation);

Removes a reference from an animation. It will be destroyed when the reference count drops to zero. At that point, all the frames in the animation will be freed and their corresponding pixbufs will be unreferenced.

animation : An animation.

See Also

GdkPixbufLoader