mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-16 05:34:00 -04:00
sixel: add: use de-reference the term struct for each access to the backing image
This commit is contained in:
parent
8c65c68b73
commit
ab70b4f16a
1 changed files with 10 additions and 7 deletions
17
sixel.c
17
sixel.c
|
|
@ -919,14 +919,17 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
|
||||||
{
|
{
|
||||||
//LOG_DBG("adding sixel %02hhx using color 0x%06x", sixel, color);
|
//LOG_DBG("adding sixel %02hhx using color 0x%06x", sixel, color);
|
||||||
|
|
||||||
if (term->sixel.pos.col >= term->sixel.image.width ||
|
int height = term->sixel.image.height;
|
||||||
term->sixel.pos.row >= term->sixel.image.height)
|
int width = term->sixel.image.width;
|
||||||
|
|
||||||
|
if (term->sixel.pos.col >= width ||
|
||||||
|
term->sixel.pos.row >= height)
|
||||||
{
|
{
|
||||||
int width = max(
|
width = max(
|
||||||
term->sixel.image.width,
|
term->sixel.image.width,
|
||||||
max(term->sixel.max_col, term->sixel.pos.col + 1));
|
max(term->sixel.max_col, term->sixel.pos.col + 1));
|
||||||
|
|
||||||
int height = max(
|
height = max(
|
||||||
term->sixel.image.height, term->sixel.pos.row + 6);
|
term->sixel.image.height, term->sixel.pos.row + 6);
|
||||||
|
|
||||||
if (!resize(term, width, height))
|
if (!resize(term, width, height))
|
||||||
|
|
@ -934,11 +937,11 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ofs = term->sixel.row_byte_ofs + term->sixel.pos.col;
|
size_t ofs = term->sixel.row_byte_ofs + term->sixel.pos.col;
|
||||||
|
uint32_t *data = term->sixel.image.data;
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++, sixel >>= 1) {
|
for (int i = 0; i < 6; i++, sixel >>= 1, ofs += width) {
|
||||||
if (sixel & 1)
|
if (sixel & 1)
|
||||||
term->sixel.image.data[ofs] = color;
|
data[ofs] = color;
|
||||||
ofs += term->sixel.image.width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xassert(sixel == 0);
|
xassert(sixel == 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue