Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::Gdk::PixbufAnimation Class Reference

A GdkPixbufAnimation C++ wrapper class. More...

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

Inheritance diagram for Inti::Gdk::PixbufAnimation:

Inti::G::Object Inti::G::TypeInstance Inti::MemoryHandler Inti::ReferencedBase List of all members.

Public Member Functions

Constructors
Accessors

Protected Member Functions

Constructors

Detailed Description

A GdkPixbufAnimation C++ wrapper class.

PixbufAnimation 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.


Constructor & Destructor Documentation

Inti::Gdk::PixbufAnimation::PixbufAnimation GdkPixbufAnimation *  pixbuf_animation,
bool  reference = true
[explicit, protected]
 

Construct a new PixbufAnimation from an existing GdkPixbufAnimation.

Parameters:
pixbuf_animation A pointer to a GdkPixbufAnimation.
reference Set false if the initial reference count is floating, set true if it's not.

The pixbuf_animation can be a newly created GdkPixbufAnimation or an existing GdkPixbufAnimation. (see G::Object::Object).

Inti::Gdk::PixbufAnimation::PixbufAnimation const String filename,
G::Error error
 

Constructs a new animation by loading it from a file.

Parameters:
filename Ther name of file to load.
error The return location for any error.

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. Possible error conditions include: 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.


Member Function Documentation

Pointer<PixbufAnimationIter> Inti::Gdk::PixbufAnimation::get_iter const GTimeVal *  start_time = 0  )  const
 

Get an iterator for displaying an animation.

Parameters:
start_time The time when the animation starts playing, or null to automatically use the result of g_get_current_time().
Returns:
An iterator to move over the animation

The iterator provides the frames that should be displayed at a given time. start_time would normally come from g_get_current_time(), and marks the beginning of animation playback. After creating an iterator, you should immediately display the pixbuf returned by Gdk::PixbufAnimationIter::get_pixbuf(). Then, you should install a timeout (with g_timeout_add()) or by some other mechanism to ensure that you'll update the image after Gdk::PixbufAnimationIter::get_delay_time() milliseconds. Each time the image is updated, you should reinstall the timeout with the new, possibly-changed delay time. As a shortcut, if start_time is null, the result of g_get_current_time() will be used automatically.

To update the image (i.e. possibly change the result of Gdk::PixbufAnimationIter::get_pixbuf() to a new frame of the animation), call Gdk::PixbufAnimationIter::advance().

If you're using PixbufLoader, in addition to updating the image after the delay time, you should also update it whenever you receive the area_updated signal and Gdk::PixbufAnimationIter::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."

Pixbuf* Inti::Gdk::PixbufAnimation::get_static_image  )  const
 

If an animation is really just a plain image (has only one frame), this method returns that image.

Returns:
An unanimated image representing the animation.

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.

bool Inti::Gdk::PixbufAnimation::is_static_image  )  const
 

If you load a file and it turns out to be a plain, unanimated image, then this method will return true.

Returns:
true if the "animation" was really just an image.

Use get_static_image() to retrieve the image.


The documentation for this class was generated from the following file: Main Page - Footer


Generated on Sun Sep 14 20:08:11 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002