ncvisual_blitset_geom: no pixel size checks for scale/stretch #1572

pull/1589/head
nick black 3 years ago
parent 311fbfa8e8
commit dc87bd7c79
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -158,15 +158,19 @@ ncvisual_blitset_geom(const notcurses* nc, const ncvisual* n,
logerror(nc, "Non-origin x placement %d for sprixel\n", vopts->x);
return -1;
}
int rows = (*leny + nc->tcache.cellpixy - 1) / nc->tcache.cellpixy;
if(rows > ncplane_dim_y(vopts->n) * nc->tcache.cellpixy){
logerror(nc, "Sprixel too tall %d for plane %d\n", *leny, ncplane_dim_y(vopts->n) * nc->tcache.cellpixy);
return -1;
}
int cols = (*lenx + nc->tcache.cellpixx - 1) / nc->tcache.cellpixx;
if(cols > ncplane_dim_x(vopts->n) * nc->tcache.cellpixx){
logerror(nc, "Sprixel too wide %d for plane %d\n", *lenx, ncplane_dim_x(vopts->n) * nc->tcache.cellpixx);
return -1;
// FIXME clamp to sprixel limits
if(vopts->scaling == NCSCALE_NONE || vopts->scaling == NCSCALE_NONE_HIRES){
int rows = (*leny + nc->tcache.cellpixy - 1) / nc->tcache.cellpixy;
fprintf(stderr, "rows: %d dim: %d\n", rows, ncplane_dim_y(vopts->n));
if(rows > ncplane_dim_y(vopts->n)){
logerror(nc, "Sprixel too tall %d for plane %d\n", *leny, ncplane_dim_y(vopts->n) * nc->tcache.cellpixy);
return -1;
}
int cols = (*lenx + nc->tcache.cellpixx - 1) / nc->tcache.cellpixx;
if(cols > ncplane_dim_x(vopts->n)){
logerror(nc, "Sprixel too wide %d for plane %d\n", *lenx, ncplane_dim_x(vopts->n) * nc->tcache.cellpixx);
return -1;
}
}
}
}

@ -48,7 +48,7 @@ TEST_CASE("Bitmaps") {
// a sprixel requires a plane large enough to hold it
SUBCASE("SprixelTooTall") {
auto y = nc_->tcache.cellpixy + 1;
auto y = nc_->tcache.cellpixy + 6;
auto x = nc_->tcache.cellpixx;
std::vector<uint32_t> v(x * y, htole(0xe61c28ff));
auto ncv = ncvisual_from_rgba(v.data(), y, sizeof(decltype(v)::value_type) * x, x);

Loading…
Cancel
Save