From e0f1a4ae33168ad1dd5d3c01fab0acadcb964943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 16 May 2021 10:57:43 +0200 Subject: [PATCH] =?UTF-8?q?sixel:=20don=E2=80=99t=20*ever*=20shrink=20imag?= =?UTF-8?q?e=20below=20its=20SRA=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the image was accompanied with a “Set Raster Attributes” (SRA) command, make sure we *never* shrink the image below the size specified in the SRA. Images are normally shrunk when their bottom rows are fully transparent. This enables sixels that aren’t a multiple of 6 to be emitted, without also emitting an SRA command. But if there *is* an SRA command, obey it. Verified against XTerm-367 --- CHANGELOG.md | 2 ++ sixel.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c225a576..34c12bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,8 @@ * Font underlines being positioned below the cell (and thus being invisible) for certain combinations of fonts and font sizes (https://codeberg.org/dnkl/foot/issues/503). +* Sixels with transparent bottom border being resized below the size + specified in _”Set Raster Attributes”_. ### Security diff --git a/sixel.c b/sixel.c index 5840e887..eb34b646 100644 --- a/sixel.c +++ b/sixel.c @@ -816,7 +816,8 @@ sixel_unhook(struct terminal *term) xassert(image.rows <= term->grid->num_rows); xassert(image.pos.row + image.rows - 1 < term->grid->num_rows); - LOG_DBG("generating %dx%d pixman image at %d-%d", + LOG_DBG("generating %s %dx%d pixman image at %d-%d", + image.opaque ? "opaque" : "transparent", image.width, image.height, image.pos.row, image.pos.row + image.rows); @@ -1195,11 +1196,10 @@ decgra(struct terminal *term, uint8_t c) ph <= term->sixel.max_height && pv <= term->sixel.max_width) { resize(term, ph, pv); - if (!term->sixel.transparent_bg) { - /* This ensures the sixel’s final image size is *at - * least* this large */ - term->sixel.max_non_empty_row_no = pv - 1; - } + + /* This ensures the sixel’s final image size is *at least* + * this large */ + term->sixel.max_non_empty_row_no = pv - 1; } term->sixel.state = SIXEL_DECSIXEL;