mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-28 07:58:00 -04:00
sixel: hopefully handle image height correctly when trimming
When trimming trailing empty rows from the final image, handle the RA region correctly: * If image is transparent, trim down to the last non-empty pixel row, regardless of whether it is inside or outside the RA region. * If image is opaque, trim down to either the last non-empty pixel row, or the RA region, whatever is the largest height.
This commit is contained in:
parent
cb820a498b
commit
bce1d7313d
1 changed files with 16 additions and 4 deletions
20
sixel.c
20
sixel.c
|
|
@ -1148,11 +1148,23 @@ sixel_unhook(struct terminal *term)
|
||||||
*
|
*
|
||||||
* See https://raw.githubusercontent.com/hackerb9/vt340test/main/sixeltests/p2effect.sh
|
* See https://raw.githubusercontent.com/hackerb9/vt340test/main/sixeltests/p2effect.sh
|
||||||
*/
|
*/
|
||||||
if (term->sixel.pos.row + 6 * term->sixel.pan >= term->sixel.image.alloc_height &&
|
if (term->sixel.pos.row + 6 * term->sixel.pan >= term->sixel.image.alloc_height) {
|
||||||
term->sixel.transparent_bg)
|
|
||||||
{
|
|
||||||
LOG_DBG("trimming image");
|
LOG_DBG("trimming image");
|
||||||
term->sixel.image.height = term->sixel.image.alloc_height - rows_to_trim * term->sixel.pan;
|
const int trimmed_height =
|
||||||
|
term->sixel.image.alloc_height - rows_to_trim * term->sixel.pan;
|
||||||
|
|
||||||
|
if (term->sixel.transparent_bg) {
|
||||||
|
/* Image is transparent - trim as much as possible */
|
||||||
|
term->sixel.image.height = trimmed_height;
|
||||||
|
} else {
|
||||||
|
/* Image is opaque. We can't trim anything "inside"
|
||||||
|
the RA region */
|
||||||
|
if (trimmed_height > term->sixel.image.height) {
|
||||||
|
/* There are non-empty pixels *outside* the RA
|
||||||
|
region - trim up to that point */
|
||||||
|
term->sixel.image.height = trimmed_height;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_DBG("only adjusting cursor position");
|
LOG_DBG("only adjusting cursor position");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue