aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-10-03 20:42:34 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-10-11 17:25:24 +0000
commit368305aa598aef4de84cb5823229a7d954a7e371 (patch)
tree9cb04eb7d69e230d731c6d7e55a71646502d8370
parentsixel: overwrite: remove asserts (diff)
sixel: overwrite: calculate split-up image pieces’ rows/cols from their width/height
-rw-r--r--sixel.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/sixel.c b/sixel.c
index 84a3ec96..88da4e28 100644
--- a/sixel.c
+++ b/sixel.c
@@ -232,8 +232,6 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
imgs[0] = (struct sixel){
.width = six->width,
.height = rel_above * term->cell_height,
- .rows = rel_above,
- .cols = six->cols,
.pos = six->pos,
};
imgs[0].data = xmalloc(imgs[0].width * imgs[0].height * sizeof(uint32_t));
@@ -244,8 +242,6 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
imgs[1] = (struct sixel){
.width = six->width,
.height = six->height - rel_below * term->cell_height,
- .rows = six->rows - rel_below,
- .cols = six->cols,
.pos = (struct coord){
six->pos.col,
(six->pos.row + rel_below) & (term->grid->num_rows - 1)},
@@ -261,8 +257,6 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
imgs[2] = (struct sixel){
.width = rel_left * term->cell_width,
.height = min(term->cell_height, six->height - rel_above * term->cell_height),
- .rows = 1,
- .cols = rel_left,
.pos = (struct coord){
six->pos.col,
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
@@ -279,8 +273,6 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
imgs[3] = (struct sixel){
.width = six->width - rel_right * term->cell_width,
.height = min(term->cell_height, six->height - rel_above * term->cell_height),
- .rows = 1,
- .cols = six->cols - rel_right,
.pos = (struct coord){
six->pos.col + rel_right,
(six->pos.row + rel_above) & (term->grid->num_rows - 1)},
@@ -297,6 +289,9 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
if (imgs[i].data == NULL)
continue;
+ imgs[i].rows = (imgs[i].height + term->cell_height - 1) / term->cell_height;
+ imgs[i].cols = (imgs[i].width + term->cell_width - 1) / term->cell_width;
+
imgs[i].pix = pixman_image_create_bits_no_clear(
PIXMAN_a8r8g8b8,
imgs[i].width, imgs[i].height,