mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
sixel: initialize max_non_empty_row_no to -1, not 0
0 is a perfectly valid row number, and if max_non_empty_row_no==0, that means we have *1* sixel row, and after trimming the image, the image will have a height of 6 pixels. If the sixel sequence is empty (or at least doesn’t emit any non-empty pixels), then trimming the image should result in an image height of 0. When max_non_empty_row_no is initialized to -1, it will still have that value in unhook(), which makes the final image height 0.
This commit is contained in:
parent
a8c5168516
commit
3566be591a
1 changed files with 7 additions and 3 deletions
10
sixel.c
10
sixel.c
|
|
@ -48,7 +48,7 @@ sixel_init(struct terminal *term, int p1, int p2, int p3)
|
|||
|
||||
term->sixel.state = SIXEL_DECSIXEL;
|
||||
term->sixel.pos = (struct coord){0, 0};
|
||||
term->sixel.max_non_empty_row_no = 0;
|
||||
term->sixel.max_non_empty_row_no = -1;
|
||||
term->sixel.row_byte_ofs = 0;
|
||||
term->sixel.color_idx = 0;
|
||||
term->sixel.param = 0;
|
||||
|
|
@ -1032,7 +1032,7 @@ sixel_add(struct terminal *term, int col, int width, uint32_t color, uint8_t six
|
|||
size_t ofs = term->sixel.row_byte_ofs + col;
|
||||
uint32_t *data = &term->sixel.image.data[ofs];
|
||||
|
||||
int max_non_empty_row = 0;
|
||||
int max_non_empty_row = -1;
|
||||
int row = term->sixel.pos.row;
|
||||
|
||||
for (int i = 0; i < 6; i++, sixel >>= 1, data += width) {
|
||||
|
|
@ -1175,7 +1175,11 @@ decgra(struct terminal *term, uint8_t c)
|
|||
ph <= term->sixel.max_height && pv <= term->sixel.max_width)
|
||||
{
|
||||
resize(term, ph, pv);
|
||||
term->sixel.max_non_empty_row_no = pv - 1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
term->sixel.state = SIXEL_DECSIXEL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue