aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-06 18:41:28 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:55 +0000
commit6658740982782daadfc52eb032e8223cddb495c2 (patch)
treea23f0c6abd360b4870a87b7b35e71caacd38d608 /sixel.c
parentmeson: SOURCE_DIR is not a valid macro in custom_target() (diff)
sixel: store current row position in pixels, not characters
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sixel.c b/sixel.c
index 6d57b6c4..bab34015 100644
--- a/sixel.c
+++ b/sixel.c
@@ -902,21 +902,20 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
//LOG_DBG("adding sixel %02hhx using color 0x%06x", sixel, color);
if (term->sixel.pos.col >= term->sixel.max_width ||
- term->sixel.pos.row * 6 + 5 >= term->sixel.max_height)
+ term->sixel.pos.row + 5 >= term->sixel.max_height)
{
return;
}
if (term->sixel.pos.col >= term->sixel.image.width ||
- term->sixel.pos.row * 6 + 5 >= (term->sixel.image.height + 6 - 1) / 6 * 6)
+ term->sixel.pos.row + 5 >= (term->sixel.image.height + 6 - 1) / 6 * 6)
{
int width = max(
term->sixel.image.width,
max(term->sixel.max_col, term->sixel.pos.col + 1));
int height = max(
- term->sixel.image.height,
- (term->sixel.pos.row + 1) * 6);
+ term->sixel.image.height, term->sixel.pos.row + 1);
if (!resize(term, width, height))
return;
@@ -924,7 +923,7 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
for (int i = 0; i < 6; i++, sixel >>= 1) {
if (sixel & 1) {
- size_t pixel_row = term->sixel.pos.row * 6 + i;
+ size_t pixel_row = term->sixel.pos.row + i;
size_t stride = term->sixel.image.width;
size_t idx = pixel_row * stride + term->sixel.pos.col;
term->sixel.image.data[idx] = color_with_alpha(term, color);
@@ -967,7 +966,7 @@ decsixel(struct terminal *term, uint8_t c)
case '-':
if (term->sixel.pos.col > term->sixel.max_col)
term->sixel.max_col = term->sixel.pos.col;
- term->sixel.pos.row++;
+ term->sixel.pos.row += 6;
term->sixel.pos.col = 0;
break;