mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-15 08:21:03 -04:00
sixel: apply background alpha when P2=0 or P2=2, and current bg color is the default bg color
Closes #1360
This commit is contained in:
parent
b4e418f251
commit
1433a81c08
2 changed files with 24 additions and 4 deletions
|
|
@ -61,6 +61,12 @@
|
||||||
name is still recognized, but will log a deprecation warning.
|
name is still recognized, but will log a deprecation warning.
|
||||||
* Meson option `default-utempter-path` renamed to
|
* Meson option `default-utempter-path` renamed to
|
||||||
`utmp-default-helper-path`.
|
`utmp-default-helper-path`.
|
||||||
|
* Opaque sixels now retain the background opacity (when current
|
||||||
|
background color is the **default** background color)
|
||||||
|
([#1360][1360]).
|
||||||
|
|
||||||
|
[1360]: https://codeberg.org/dnkl/foot/issues/1360
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
|
|
||||||
22
sixel.c
22
sixel.c
|
|
@ -73,22 +73,36 @@ sixel_init(struct terminal *term, int p1, int p2, int p3)
|
||||||
|
|
||||||
switch (term->vt.attrs.bg_src) {
|
switch (term->vt.attrs.bg_src) {
|
||||||
case COLOR_RGB:
|
case COLOR_RGB:
|
||||||
bg = term->vt.attrs.bg;
|
bg = 0xffu << 24 | term->vt.attrs.bg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_BASE16:
|
case COLOR_BASE16:
|
||||||
case COLOR_BASE256:
|
case COLOR_BASE256:
|
||||||
bg = term->colors.table[term->vt.attrs.bg];
|
bg = 0xffu << 24 | term->colors.table[term->vt.attrs.bg];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_DEFAULT:
|
case COLOR_DEFAULT:
|
||||||
bg = term->colors.bg;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
term->sixel.default_bg = term->sixel.transparent_bg
|
term->sixel.default_bg = term->sixel.transparent_bg
|
||||||
? 0x00000000u
|
? 0x00000000u
|
||||||
: 0xffu << 24 | bg;
|
: bg;
|
||||||
|
|
||||||
for (size_t i = 0; i < 1 * 6; i++)
|
for (size_t i = 0; i < 1 * 6; i++)
|
||||||
term->sixel.image.data[i] = term->sixel.default_bg;
|
term->sixel.image.data[i] = term->sixel.default_bg;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue