class GdkPixbuf::PixbufAnimation
- GdkPixbuf::PixbufAnimation
- GObject::Object
- Reference
- Object
Overview
An opaque object representing an animation.
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.
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.
Direct Known Subclasses
Defined in:
lib/gi-crystal/src/auto/gdk_pixbuf-2.0/pixbuf_animation.crConstructors
-
.new
Initialize a new
PixbufAnimation
.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
-
.new_from_file(filename : String) : self | Nil
Creates a new animation by loading it from a file.
-
.new_from_resource(resource_path : String) : self | Nil
Creates a new pixbuf animation by loading an image from an resource.
-
.new_from_stream(stream : Gio::InputStream, cancellable : Gio::Cancellable | Nil) : self | Nil
Creates a new animation by loading it from an input stream.
-
.new_from_stream_async(stream : Gio::InputStream, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil
Creates a new animation by asynchronously loading an image from an input stream.
-
.new_from_stream_finish(async_result : Gio::AsyncResult) : self | Nil
Finishes an asynchronous pixbuf animation creation operation started with
Gdk::Pixbuf::PixbufAnimation#new_from_stream_async
.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#hash(hasher)
See
Object#hash(hasher)
-
#height : Int32
Queries the height of the bounding box of a pixbuf animation.
-
#is_static_image : Bool
Checks whether the animation is a static image.
-
#iter(start_time : GLib::TimeVal | Nil) : GdkPixbuf::PixbufAnimationIter
Get an iterator for displaying an animation.
-
#static_image : GdkPixbuf::Pixbuf
Retrieves a static image for the animation.
-
#width : Int32
Queries the width of the bounding box of a pixbuf animation.
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Returns the type id (GType) registered in GLib type system.
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.
Creates a new pixbuf animation by loading an image from an resource.
The file format is detected automatically. If NULL
is returned, then error will be set.
Creates a new animation by loading it from an input stream.
The file format is detected automatically.
If NULL
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.
Creates a new animation by asynchronously loading an image from an input stream.
For more details see gdk_pixbuf_new_from_stream(), which is the synchronous version of this function.
When the operation is finished, callback
will be called in the main thread.
You can then call gdk_pixbuf_animation_new_from_stream_finish() to get the
result of the operation.
Finishes an asynchronous pixbuf animation creation operation started with
Gdk::Pixbuf::PixbufAnimation#new_from_stream_async
.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Checks whether the animation is a static image.
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.
Get an iterator for displaying an 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_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 NULL
, 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".
Retrieves a static image for the 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 image to use as a static unanimated image, which might be the first frame, or something more sophisticated depending on the file format.
If an animation hasn't loaded any frames yet, this function will
return NULL
.