terminal/c: image data returns the current animation frame

This commit is contained in:
Mitchell Hashimoto
2026-08-20 21:13:18 -07:00
parent d2ffeb5ba5
commit 73903f76aa
2 changed files with 11 additions and 2 deletions

View File

@@ -399,6 +399,12 @@ typedef enum GHOSTTY_ENUM_TYPED {
* time, before the image is stored. Consumers can upload this
* directly to the GPU without any decode step.
*
* For an animated image (Kitty graphics animation, actions a=f/a=a)
* this is the pixel data of the current animation frame. The
* image's GHOSTTY_KITTY_IMAGE_DATA_GENERATION changes whenever the
* current frame changes, so generation-keyed caches remain
* coherent.
*
* Output type: const uint8_t **
*/
GHOSTTY_KITTY_IMAGE_DATA_DATA_PTR = 7,

View File

@@ -262,8 +262,11 @@ fn imageGetTyped(
.height => out.* = image.height,
.format => out.* = image.format,
.compression => out.* = image.compression,
.data_ptr => out.* = (image.data.bytes() orelse return .no_value).ptr,
.data_len => out.* = image.data.len(),
// For animated images this is the current animation frame's
// data; the image generation changes whenever the current
// frame does, so generation-keyed caches stay coherent.
.data_ptr => out.* = (image.renderData().bytes() orelse return .no_value).ptr,
.data_len => out.* = image.renderData().len(),
.generation => out.* = image.generation,
}