canvaskit-wasm 0.39 build 2026-04-29

AnimatedImage

A multi-frame decoded image — animated GIFs, animated WebP, APNG. Returned by CK.MakeAnimatedImageFromEncoded(bytes). You step through frames manually with decodeNextFrame() and snapshot the current frame as a still Image via makeImageAtCurrentFrame().

AnimatedImage is a WASM object — call delete() when done.

// Pseudocode — most browsers don't ship WASM-friendly animated GIFs in our examples.
// const bytes = await fetch('/img/spinner.gif').then(r => r.arrayBuffer());
// const anim = CK.MakeAnimatedImageFromEncoded(new Uint8Array(bytes));
// loop(() => {
//   const frame = anim.makeImageAtCurrentFrame();
//   canvas.drawImage(frame, 0, 0, null);
//   frame.delete();
//   anim.decodeNextFrame();
//   surface.flush();
// });
// anim.delete();

Members

MemberArgsReturnsNotes
currentFrameDurationnumberDisplay duration of the current frame, in milliseconds.
decodeNextFramenumberAdvance to the next frame; returns its duration in ms (or -1 if iteration ended).
deletevoidFree the WASM memory. Required.
getFrameCountnumberTotal number of frames.
getRepetitionCountnumberHow many times the animation should repeat (0 = forever, -1 = unknown, n = exactly n loops).
heightnumberImage height in pixels.
makeImageAtCurrentFrameImageSnapshot the current frame as a still Image. Caller deletes.
widthnumberImage width in pixels.

See also