KiteAnimation

class KiteAnimation(val width: Int, val height: Int, val frames: List<KiteFrame>, val loopCount: Long)(source)

A decoded animation: GIF, APNG, animated WebP, animated AVIF and animated JPEG XL all arrive in this shape. Static images decode as a single frame, so ImageKodec.decodeAnimation is total over every supported format.

loopCount means the same thing in all three formats: 0 = loop forever, n > 0 = play the sequence n times. A file that carries no loop count at all gets 1 (play once), which is what its absence has always meant in practice.

loopCount is a Long so APNG's full four-byte play field is preserved, including counts above the PNG Third Edition integer limit accepted for compatibility with deployed APNG writers.

Throws

if frames is empty or loopCount is negative

Constructors

Link copied to clipboard
constructor(width: Int, height: Int, frames: List<KiteFrame>, loopCount: Long)

Properties

Link copied to clipboard

Sum of frame delays for one loop, in milliseconds. It stops at Int.MAX_VALUE instead of wrapping.

Link copied to clipboard
Link copied to clipboard
val height: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val width: Int

Functions

Link copied to clipboard
fun KiteAnimation.cropped(x: Int, y: Int, width: Int, height: Int): KiteAnimation

cropped applied to every frame, preserving delays and loop count.

Link copied to clipboard
fun KiteAnimation.downscaledTo(targetWidth: Int, targetHeight: Int): KiteAnimation

Downscale every frame to exactly targetWidth×targetHeight with KiteBitmap.downscaledTo, preserving delays and the play count. Equal canvas dimensions return this instance.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

oriented applied to every frame, preserving delays and loop count.

Link copied to clipboard

rotated180 applied to every frame.

Link copied to clipboard

rotated270 applied to every frame.

Link copied to clipboard

rotated90 applied to every frame.

Link copied to clipboard
fun KiteAnimation.scaled(maxWidth: Int, maxHeight: Int): KiteAnimation

Downscale every frame of an animation to fit inside maxWidth×maxHeight (same box filter and aspect handling as KiteBitmap.scaled), preserving delays and the loop count. This is where animated memory goes: a full-screen GIF shown as an avatar keeps W×H×4 bytes per frame unless scaled down.

Link copied to clipboard

transposed applied to every frame.

Link copied to clipboard

transversed applied to every frame.