Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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.
Synopsis
- newtype PixbufAnimation = PixbufAnimation (ManagedPtr PixbufAnimation)
- class (GObject o, IsDescendantOf PixbufAnimation o) => IsPixbufAnimation o
- toPixbufAnimation :: (MonadIO m, IsPixbufAnimation o) => o -> m PixbufAnimation
- pixbufAnimationGetHeight :: (HasCallStack, MonadIO m, IsPixbufAnimation a) => a -> m Int32
- pixbufAnimationGetIter :: (HasCallStack, MonadIO m, IsPixbufAnimation a) => a -> Maybe TimeVal -> m PixbufAnimationIter
- pixbufAnimationGetStaticImage :: (HasCallStack, MonadIO m, IsPixbufAnimation a) => a -> m Pixbuf
- pixbufAnimationGetWidth :: (HasCallStack, MonadIO m, IsPixbufAnimation a) => a -> m Int32
- pixbufAnimationIsStaticImage :: (HasCallStack, MonadIO m, IsPixbufAnimation a) => a -> m Bool
- pixbufAnimationNewFromFile :: (HasCallStack, MonadIO m) => [Char] -> m (Maybe PixbufAnimation)
- pixbufAnimationNewFromResource :: (HasCallStack, MonadIO m) => Text -> m (Maybe PixbufAnimation)
- pixbufAnimationNewFromStream :: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) => a -> Maybe b -> m (Maybe PixbufAnimation)
- pixbufAnimationNewFromStreamAsync :: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- pixbufAnimationNewFromStreamFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> m (Maybe PixbufAnimation)
Exported types
newtype PixbufAnimation Source #
Memory-managed wrapper type.
PixbufAnimation (ManagedPtr PixbufAnimation) |
Instances
class (GObject o, IsDescendantOf PixbufAnimation o) => IsPixbufAnimation o Source #
Type class for types which can be safely cast to PixbufAnimation
, for instance with toPixbufAnimation
.
Instances
(GObject o, IsDescendantOf PixbufAnimation o) => IsPixbufAnimation o Source # | |
Defined in GI.GdkPixbuf.Objects.PixbufAnimation |
toPixbufAnimation :: (MonadIO m, IsPixbufAnimation o) => o -> m PixbufAnimation Source #
Cast to PixbufAnimation
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, isStaticImage, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getHeight, getIter, getProperty, getQdata, getStaticImage, getWidth.
Setters
getHeight
pixbufAnimationGetHeight Source #
:: (HasCallStack, MonadIO m, IsPixbufAnimation a) | |
=> a |
|
-> m Int32 | Returns: Height of the bounding box of the animation. |
Queries the height of the bounding box of a pixbuf animation.
getIter
pixbufAnimationGetIter Source #
:: (HasCallStack, MonadIO m, IsPixbufAnimation a) | |
=> a |
|
-> Maybe TimeVal |
|
-> m PixbufAnimationIter | Returns: an iterator to move over the animation |
Get an iterator for displaying an animation.
The iterator provides the frames that should be displayed at a given time.
startTime
would normally come from getCurrentTime
, and marks
the beginning of animation playback. After creating an iterator, you
should immediately display the pixbuf returned by
pixbufAnimationIterGetPixbuf
. Then, you should install
a timeout (with g_timeout_add()
) or by some other mechanism ensure
that you'll update the image after
pixbufAnimationIterGetDelayTime
milliseconds. Each time
the image is updated, you should reinstall the timeout with the new,
possibly-changed delay time.
As a shortcut, if startTime
is NULL
, the result of
getCurrentTime
will be used automatically.
To update the image (i.e. possibly change the result of
pixbufAnimationIterGetPixbuf
to a new frame of the animation),
call pixbufAnimationIterAdvance
.
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
pixbufAnimationIterOnCurrentlyLoadingFrame
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".
getStaticImage
pixbufAnimationGetStaticImage Source #
:: (HasCallStack, MonadIO m, IsPixbufAnimation a) | |
=> a |
|
-> m Pixbuf | Returns: unanimated image representing the animation |
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
.
getWidth
pixbufAnimationGetWidth Source #
:: (HasCallStack, MonadIO m, IsPixbufAnimation a) | |
=> a |
|
-> m Int32 | Returns: Width of the bounding box of the animation. |
Queries the width of the bounding box of a pixbuf animation.
isStaticImage
pixbufAnimationIsStaticImage Source #
:: (HasCallStack, MonadIO m, IsPixbufAnimation a) | |
=> a |
|
-> m Bool | Returns: |
Checks whether the animation is a static image.
If you load a file with pixbufAnimationNewFromFile
and it
turns out to be a plain, unanimated image, then this function will
return TRUE
. Use pixbufAnimationGetStaticImage
to retrieve
the image.
newFromFile
pixbufAnimationNewFromFile Source #
:: (HasCallStack, MonadIO m) | |
=> [Char] |
|
-> m (Maybe PixbufAnimation) | Returns: A newly-created animation (Can throw |
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.
newFromResource
pixbufAnimationNewFromResource Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Maybe PixbufAnimation) | Returns: A newly-created animation (Can throw |
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.
Since: 2.28
newFromStream
pixbufAnimationNewFromStream Source #
:: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (Maybe PixbufAnimation) | Returns: A newly-created animation (Can throw |
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.
Since: 2.28
newFromStreamAsync
pixbufAnimationNewFromStreamAsync Source #
:: (HasCallStack, MonadIO m, IsInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Creates a new animation by asynchronously loading an image from an input stream.
For more details see pixbufNewFromStream
, 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 pixbufAnimationNewFromStreamFinish
to get the
result of the operation.
Since: 2.28
newFromStreamFinish
pixbufAnimationNewFromStreamFinish Source #
:: (HasCallStack, MonadIO m, IsAsyncResult a) | |
=> a |
|
-> m (Maybe PixbufAnimation) | Returns: the newly created animation (Can throw |
Finishes an asynchronous pixbuf animation creation operation started with
[funcgdkPixbuf
.PixbufAnimation.new_from_stream_async].
Since: 2.28