Animations

Name

Animations -- Animated images.

Synopsis


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


enum        GdkPixbufFrameAction;
struct      GdkPixbufFrame;
struct      GdkPixbufAnimation;
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);


Description

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.

Details

enum GdkPixbufFrameAction

typedef enum {
        /* Keep this frame and composite next frame over it */
        /* (GIF disposal method 1) */
	GDK_PIXBUF_FRAME_RETAIN,
        /* Revert to background color before compositing next frame */
        /* (GIF disposal method 2) */
	GDK_PIXBUF_FRAME_DISPOSE,
        /* Revert to previously-displayed composite image after
         * displaying this frame
         */
        /* (GIF disposal method 3) */
	GDK_PIXBUF_FRAME_REVERT
} GdkPixbufFrameAction;


struct GdkPixbufFrame

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

        /* Offsets for overlaying onto the GIF graphic area */
        int x_offset;
	int y_offset;

	/* Frame duration in ms */
	int delay_time;

        /* Sum of preceding delay times */
        int elapsed;
        
        /* Overlay mode */
	GdkPixbufFrameAction action;

        /* TRUE if the pixbuf has been modified since
         * the last frame composite operation
         */
        gboolean need_recomposite;

        /* TRUE if the background for this frame is transparent */
        gboolean bg_transparent;
        
        /* The below reflects the "use hell of a lot of RAM"
         * philosophy of coding
         */
        
        /* Cached composite image (the image you actually display
         * for this frame)
         */
        GdkPixbuf *composited;

        /* Cached revert image (the contents of the area
         * covered by the frame prior to compositing;
         * same size as pixbuf, not as the composite image; only
         * used for FRAME_REVERT frames)
         */
        GdkPixbuf *revert;
};


struct GdkPixbufAnimation

struct GdkPixbufAnimation;

This object describes an animation.


gdk_pixbuf_animation_new_from_file ()

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 G_FILE_ERROR domains.

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.


gdk_pixbuf_animation_ref ()

GdkPixbufAnimation* gdk_pixbuf_animation_ref
                                            (GdkPixbufAnimation *animation);

Adds a reference to an animation. Deprecated; use g_object_ref(). The reference must be released afterwards using g_object_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. Deprecated; use g_object_unref().

animation : An animation.


gdk_pixbuf_animation_get_width ()

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.


gdk_pixbuf_animation_get_height ()

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.

See Also

GdkPixbufLoader