From ffca3de583bf4b1605cf461bb7ac1e39049142df Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 25 Jan 2022 14:03:49 -0500 Subject: [PATCH] [sixel] rmatrix is per-cell, not per-pixel --- src/lib/sixel.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 8846bb02b..d167a3bbd 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -757,8 +757,14 @@ extract_color_table(const uint32_t* data, int linesize, int cols, // calculate the cell geometry const int ccols = (lenx + cdimx - 1) / cdimx; const int crows = (leny + cdimy - 1) / cdimy; + typeof(bargs->u.pixel.spx->needs_refresh) rmatrix; + rmatrix = malloc(sizeof(*rmatrix) * crows * ccols); + if(rmatrix == NULL){ + free_qstate(&qs); + return -1; + } + bargs->u.pixel.spx->needs_refresh = rmatrix; int pos = 0; // pixel position - unsigned char* rmatrix = bargs->u.pixel.spx->needs_refresh; for(int y = 0 ; y < crows ; ++y){ // cell row for(int x = 0 ; x < ccols ; ++x){ // cell column const int txyidx = y * ccols + x; @@ -1138,15 +1144,6 @@ int sixel_blit(ncplane* n, int linesize, const void* data, int leny, int lenx, } int cols = bargs->u.pixel.spx->dimx; int rows = bargs->u.pixel.spx->dimy; - typeof(bargs->u.pixel.spx->needs_refresh) rmatrix; - // FIXME needs_refresh is described as a per-cell deal, but this appears - // to be allocated per-pixel...? - rmatrix = malloc(sizeof(*rmatrix) * rows * cols); - if(rmatrix == NULL){ - sixelmap_free(stable.map); - return -1; - } - bargs->u.pixel.spx->needs_refresh = rmatrix; assert(n->tam); if(extract_color_table(data, linesize, cols, leny, lenx, &stable, n->tam, bargs)){ free(bargs->u.pixel.spx->needs_refresh);