Package ch.bailu.gtk.gdkpixbuf
Class PixbufAnimation
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gdkpixbuf.PixbufAnimation
- All Implemented Interfaces:
PointerInterface
- Direct Known Subclasses:
PixbufNonAnim
,PixbufSimpleAnim
An opaque object representing an animation.
The GdkPixBuf 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 `GdkPixbuf` what should
be displayed at a given point in time.
The GdkPixBuf 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 `GdkPixbuf` what should
be displayed at a given point in time.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassHandler
int
Queries the height of the bounding box of a pixbuf animation.static int
Get an iterator for displaying an animation.static long
static TypeSystem.TypeSize
Retrieves a static image for the animation.static long
static TypeSystem.TypeSize
int
getWidth()
Queries the width of the bounding box of a pixbuf animation.boolean
Checks whether the animation is a static image.static PixbufAnimation
newFromFilePixbufAnimation
(Str filename) Creates a new animation by loading it from a file.static PixbufAnimation
newFromFilePixbufAnimation
(String filename) Creates a new animation by loading it from a file.static PixbufAnimation
newFromResourcePixbufAnimation
(Str resource_path) Creates a new pixbuf animation by loading an image from an resource.static PixbufAnimation
newFromResourcePixbufAnimation
(String resource_path) Creates a new pixbuf animation by loading an image from an resource.static void
newFromStreamAsync
(InputStream stream, Cancellable cancellable, PixbufAnimation.OnAsyncReadyCallback callback, Pointer user_data) Creates a new animation by asynchronously loading an image from an input stream.static PixbufAnimation
newFromStreamFinishPixbufAnimation
(AsyncResult async_result) Finishes an asynchronous pixbuf animation creation operation started with
[func@GdkPixbuf.PixbufAnimation.new_from_stream_async].static PixbufAnimation
newFromStreamPixbufAnimation
(InputStream stream, Cancellable cancellable) Creates a new animation by loading it from an input stream.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
PixbufAnimation
-
-
Method Details
-
getClassHandler
-
newFromFilePixbufAnimation
public static PixbufAnimation newFromFilePixbufAnimation(@Nonnull Str filename) throws AllocationError 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.- Parameters:
filename
- Name of file to load, in the GLib file name encoding- Returns:
- A newly-created animation
- Throws:
AllocationError
-
newFromFilePixbufAnimation
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.- Parameters:
filename
- Name of file to load, in the GLib file name encoding- Returns:
- A newly-created animation
- Throws:
AllocationError
-
newFromResourcePixbufAnimation
public static PixbufAnimation newFromResourcePixbufAnimation(@Nonnull Str resource_path) throws AllocationError 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.- Parameters:
resource_path
- the path of the resource file- Returns:
- A newly-created animation
- Throws:
AllocationError
-
newFromResourcePixbufAnimation
public static PixbufAnimation newFromResourcePixbufAnimation(String resource_path) throws AllocationError 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.- Parameters:
resource_path
- the path of the resource file- Returns:
- A newly-created animation
- Throws:
AllocationError
-
newFromStreamPixbufAnimation
public static PixbufAnimation newFromStreamPixbufAnimation(@Nonnull InputStream stream, @Nullable Cancellable cancellable) throws AllocationError 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.- Parameters:
stream
- a `GInputStream` to load the pixbuf fromcancellable
- optional `GCancellable` object- Returns:
- A newly-created animation
- Throws:
AllocationError
-
newFromStreamFinishPixbufAnimation
public static PixbufAnimation newFromStreamFinishPixbufAnimation(@Nonnull AsyncResult async_result) throws AllocationError Finishes an asynchronous pixbuf animation creation operation started with
[func@GdkPixbuf.PixbufAnimation.new_from_stream_async].- Parameters:
async_result
- a #GAsyncResult- Returns:
- the newly created animation
- Throws:
AllocationError
-
getHeight
public int getHeight()Queries the height of the bounding box of a pixbuf animation.- Returns:
- Height of the bounding box of the animation.
-
getIter
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 #GdkPixbufLoader, 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
- time when the animation starts playing- Returns:
- an iterator to move over the animation
-
getStaticImage
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`.- Returns:
- unanimated image representing the animation
-
getWidth
public int getWidth()Queries the width of the bounding box of a pixbuf animation.- Returns:
- Width of the bounding box of the animation.
-
isStaticImage
public boolean isStaticImage()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.- Returns:
- `TRUE` if the "animation" was really just an image
-
newFromStreamAsync
public static void newFromStreamAsync(@Nonnull InputStream stream, @Nullable Cancellable cancellable, PixbufAnimation.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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.- Parameters:
stream
- a #GInputStream from which to load the animationcancellable
- optional #GCancellable objectcallback
- a `GAsyncReadyCallback` to call when the pixbuf is loadeduser_data
- the data to pass to the callback function
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-