sixel: resize: width is no longer a multiple of 6

This commit is contained in:
Daniel Eklöf 2021-03-07 12:02:12 +01:00
parent 6ab7052be4
commit d35963f584
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

20
sixel.c
View file

@ -695,10 +695,6 @@ sixel_reflow(struct terminal *term)
void
sixel_unhook(struct terminal *term)
{
/* The internal buffer always as a row number that is a multiple of 6 */
term->sixel.image.height = min(
term->sixel.image.height, term->sixel.max_height);
int pixel_row_idx = 0;
int pixel_rows_left = term->sixel.image.height;
const int stride = term->sixel.image.width * sizeof(uint32_t);
@ -847,19 +843,11 @@ resize(struct terminal *term, int new_width, int new_height)
term->sixel.image.width, term->sixel.image.height,
new_width, new_height);
if (new_width > term->sixel.max_width)
return false;
/*
* Last row may be cropped by the max height, but dont skip that
* last partial row entirely.
*
* I.e if max height is 4, then allow resizing up to 6, to allow
* us to emit that last sixel row. The final image will be cropped
* to the current max geometry in unhook.
*/
if (new_height > (term->sixel.max_height + 5) / 6 * 6)
if (new_width > term->sixel.max_width ||
new_height > term->sixel.max_height)
{
return false;
}
uint32_t *old_data = term->sixel.image.data;
const int old_width = term->sixel.image.width;