Class: GdkPixbuf::PixbufAnimation

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

An opaque struct representing an animation.

Instance Method Summary collapse

Instance Method Details

#get_iter(start_time) ⇒ GdkPixbuf::PixbufAnimationIter

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 g_object_unref().

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_pixbuf_animation_iter_get_pixbuf(). Then, you should install a timeout (with g_timeout_add()) or by some other mechanism ensure that you’ll update the image after gdk_pixbuf_animation_iter_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 nil, the result of g_get_current_time() will be used automatically.

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 Gdk::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_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.”

Parameters:

  • start_time (GLib::TimeVal)

    time when the animation starts playing

Returns:

#heightInteger

Queries the height of the bounding box of a pixbuf animation.

Returns:

  • (Integer)

    Height of the bounding box of the animation.

#is_static_imageTrueClass

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.

Returns:

  • (TrueClass)

    true if the “animation” was really just an image

#new_from_file(filename) ⇒ GdkPixbuf::PixbufAnimation

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

Parameters:

  • filename (GdkPixbuf::filename)

    Name of file to load, in the GLib file name encoding

Returns:

#new_from_resource(resource_path) ⇒ GdkPixbuf::PixbufAnimation

Creates a new pixbuf animation by loading an image from an resource.

The file format is detected automatically. If nil is returned, then error will be set. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.

Parameters:

  • resource_path (String)

    the path of the resource file

Returns:

#new_from_stream(stream, cancellable) ⇒ GdkPixbuf::PixbufAnimation

Creates a new animation by loading it from an input stream.

The file format is detected automatically. If nil is returned, then error will be set. The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. Other possible errors are in the #GDK_PIXBUF_ERROR and %G_IO_ERROR domains.

The stream is not closed. conditions occurred: the file could not be opened, the image format is not supported, there was not enough memory to allocate the image buffer, the stream contained invalid data, or the operation was cancelled.

Parameters:

Returns:

#new_from_stream_finish(async_result) ⇒ GdkPixbuf::PixbufAnimation

Finishes an asynchronous pixbuf animation creation operation started with gdk_pixbuf_animation_new_from_stream_async(). object with g_object_unref().

Parameters:

Returns:

#refGdkPixbuf::PixbufAnimation

Adds a reference to an animation.

Returns:

#static_imageGdkPixbuf::Pixbuf

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

Returns:

#unrefnil

Removes a reference from an animation.

Returns:

  • (nil)

#widthInteger

Queries the width of the bounding box of a pixbuf animation.

Returns:

  • (Integer)

    Width of the bounding box of the animation.