Skip to content

Support per-band SIXEL palette redefinition for full-color images #20588

Description

@unxed

Problem

Windows Terminal supports SIXEL, but does not correctly render a valid
full-color SIXEL stream that redefines palette entries between SIXEL bands.

This technique allows a single SIXEL image to contain far more than 256
colors: the encoder reuses the 256 palette registers for each six-pixel-high
band and redefines them before emitting the next band.

Minimal reproduction

Save this as sixel-repro.py and run it directly in Windows Terminal:

import sys

sys.stdout.buffer.write(
    b"\x1bPq"
    b'"1;1;2;12'
    b"#1;2;100;0;0!2~"
    b"$-"
    b"#1;2;0;0;100!2~"
    b"\x1b\\"
)

The first six-pixel band is red and the second one is blue.

Expected behavior

The upper band remains red and the lower band remains blue.

Actual behavior

The color of the earlier band may change when palette entry #1 is
redefined for the later band.

Technical background

The SIXEL format permits palette redefinition during a DCS sequence.
Implementations that support full-color SIXEL need to resolve the palette
color when pixels are decoded, or otherwise snapshot the RGB value before the
palette entry is changed.

This behavior is supported, for example, by
WezTerm
foot

Windows Terminal currently stores indexed pixels and resolves them against the
current color table when flushing the image, so earlier pixels can be affected
by later palette changes.

This is separate from support for multiple DCS images or layered SIXEL
images. The desired behavior is correct rendering of one DCS sequence.

Related: #20020

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Needs-Tag-FixDoesn't match tag requirementsNeeds-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions