Class KittyGraphicsEncoder
Encodes a pixel array into the Kitty terminal graphics protocol APC escape sequence stream.
public class KittyGraphicsEncoder
- Inheritance
-
KittyGraphicsEncoder
- Inherited Members
Remarks
The Kitty graphics protocol transmits images via APC sequences of the form:
ESC_G <key=value,...>;<base64-data>ESC\.
Images are encoded as raw 32-bit RGBA pixel data (no palette, no quantization), split
into chunks of at most MaxChunkSize base64 characters. Multi-chunk
transmissions set m=1 on all chunks except the last (m=0).
See https://sw.kovidgoyal.net/kitty/graphics-protocol/ for the full spec.
Constructors
Fields
- MaxChunkSize
Maximum number of base64-encoded characters per APC chunk. The Kitty protocol recommends ≤4096 bytes of payload per chunk.
Methods
- EncodeDeletePlacement(int, int)
Encodes a Kitty sequence that deletes a single placement (by image id + placement id), leaving the transmitted image data and other placements intact.
- EncodeDeletePlacements(int)
Builds a Kitty graphics protocol APC sequence that deletes all placements of the image with the specified
imageId, leaving the transmitted image data intact so it can be re-displayed.
- EncodeKitty(Color[,], int, int, int?)
Encodes the provided pixel array into a Kitty graphics protocol APC sequence string that, when written to the terminal, renders the image at the current cursor position occupying
destColscolumns anddestRowsrows.
- EncodePut(int, int, int, int, int, int, int, int)
Encodes a placement (
a=p) that displays a crop of an already-transmitted image (see EncodeTransmit(Color[,], int)) at the current cursor position. The source rectangle (srcX,srcY,srcW,srcH) in image pixels is scaled to filldestCols×destRowscells. A later placement with the same (image id, placement id) replaces this one in place — so panning/zooming a static image is a tiny, flash-free update rather than a full re-transmit.
- EncodeTransmit(Color[,], int)
Encodes a transmit-only (
a=t) Kitty sequence: it sends the full image data under the givenimageIdwithout creating a placement. The image stays resident in the terminal so it can be displayed — and re-displayed with a different crop — via EncodePut(int, int, int, int, int, int, int, int) without re-sending the pixels. Used to pan/zoom a static image with tiny per-frame placement updates instead of re-transmitting the whole image every frame (which reads as a flash for large images).
- GetImageId(string)
Derives a stable, positive, non-zero Kitty image id from the given string identifier.