sprixel_load: sanity-check pixel geometry #1560

pull/1609/head
nick black 3 years ago committed by Nick Black
parent fedcd94502
commit 5f51e15d7c

@ -146,11 +146,13 @@ sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx){
return ret;
}
// 'y' and 'x' are the cell geometry, not the pixel geometry. takes
// ownership of 's' on success. pixel geometry ought include any Sixel excess.
// |pixy| and |pixx| are the output pixel geometry (i.e. |pixy| must be a
// multiple of 6 for sixel). takes ownership of 's' on success.
int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx,
int parse_start){
assert(spx->n);
assert((pixy + s->cellpxy - 1) / s->cellpxy == s->dimy);
assert((pixx + s->cellpxx - 1) / s->cellpxx == s->dimx);
free(spx->glyph);
spx->glyph = s;
spx->glyphlen = bytes;

@ -693,9 +693,8 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
ncplane* createdn = NULL;
//fprintf(stderr, "INPUT N: %p rows: %d cols: %d 0x%016lx\n", n ? n : NULL, disppixy, disppixx, flags);
if(n == NULL){ // create plane
createdn = make_sprixel_plane(nc, ncv, scaling, &disppixy, &disppixx,
flags, &outy, &placey, &placex);
if(createdn == NULL){
if((createdn = make_sprixel_plane(nc, ncv, scaling, &disppixy, &disppixx,
flags, &outy, &placey, &placex)) == NULL){
return NULL;
}
n = createdn;

Loading…
Cancel
Save