diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-09-05 05:17:03 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-09-05 05:33:05 +0000 |
| commit | c41f55c3a0994f86aca4d6add49420a25e023ba4 (patch) | |
| tree | e904a7417e42d1d25b55b06a1f4214538d9f6065 /sixel.c | |
| parent | notifications: BEL and OSC-777 now focuses the window on notification activation (diff) | |
sixel: default bg color is now taken from the sixel palette, not the ANSI bg color
The wording in the original VT340 documentation is vague:
Pixel positions specified as 0 are set to the current background
color.
What does that mean? We _thought_ it meant the current ANSI background
color, as set with e.g. CSI 4x m.
It's still all a bit vague, but seeing that we have separate palettes
for text and graphic (should we?), it doesn't make sense to use the
ANSI background color as the default sixel background color.
So, use entry 0 from the sixel palette instead.
Diffstat (limited to 'sixel.c')
| -rw-r--r-- | sixel.c | 37 |
1 files changed, 4 insertions, 33 deletions
@@ -127,40 +127,11 @@ sixel_init(struct terminal *term, int p1, int p2, int p3) term->sixel.palette = term->sixel.shared_palette; } - uint32_t bg = 0; - - switch (term->vt.attrs.bg_src) { - case COLOR_RGB: - bg = 0xffu << 24 | term->vt.attrs.bg; - break; - - case COLOR_BASE16: - case COLOR_BASE256: - bg = 0xffu << 24 | term->colors.table[term->vt.attrs.bg]; - break; - - case COLOR_DEFAULT: - if (term->colors.alpha == 0xffff) - bg = 0xffu << 24 | term->colors.bg; - else { - /* Alpha needs to be pre-multiplied */ - uint32_t r = (term->colors.bg >> 16) & 0xff; - uint32_t g = (term->colors.bg >> 8) & 0xff; - uint32_t b = (term->colors.bg >> 0) & 0xff; - - uint32_t alpha = term->colors.alpha; - r *= alpha; r /= 0xffff; - g *= alpha; g /= 0xffff; - b *= alpha; b /= 0xffff; - - bg = (alpha >> 8) << 24 | (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff); - } - break; - } + if (term->sixel.transparent_bg) + term->sixel.default_bg = 0x00000000u; + else + term->sixel.default_bg = term->sixel.palette[0]; - term->sixel.default_bg = term->sixel.transparent_bg - ? 0x00000000u - : bg; count = 0; return pan == 1 && pad == 1 ? &sixel_put_ar_11 : &sixel_put_generic; |
