mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
run ncvisual_resize() in bitmap tests #1559
This commit is contained in:
parent
6ab072c953
commit
c3c5b397a3
4
USAGE.md
4
USAGE.md
@ -3068,8 +3068,8 @@ int ncvisual_blitter_geom(const struct notcurses* nc, const struct ncvisual* n,
|
|||||||
const struct ncvisual_options* vopts, int* y, int* x,
|
const struct ncvisual_options* vopts, int* y, int* x,
|
||||||
int* scaley, int* scalex, ncblitter_e* blitter);
|
int* scaley, int* scalex, ncblitter_e* blitter);
|
||||||
|
|
||||||
// Rotate the visual 'rads' radians. Only M_PI/2 and -M_PI/2 are
|
// Scale the visual to 'rows' X 'columns' pixels, using the best scheme
|
||||||
// supported at the moment, but this will change FIXME.
|
// available. This is a lossy transformation, unless the size is unchanged.
|
||||||
int ncvisual_rotate(struct ncvisual* n, double rads);
|
int ncvisual_rotate(struct ncvisual* n, double rads);
|
||||||
|
|
||||||
// Resize the visual so that it is 'rows' X 'columns'. This is a lossy
|
// Resize the visual so that it is 'rows' X 'columns'. This is a lossy
|
||||||
|
@ -2735,7 +2735,7 @@ API int ncvisual_decode_loop(struct ncvisual* nc)
|
|||||||
API int ncvisual_rotate(struct ncvisual* n, double rads)
|
API int ncvisual_rotate(struct ncvisual* n, double rads)
|
||||||
__attribute__ ((nonnull (1)));
|
__attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
// Resize the visual so that it is 'rows' X 'columns', using the best scheme
|
// Scale the visual to 'rows' X 'columns' pixels, using the best scheme
|
||||||
// available. This is a lossy transformation, unless the size is unchanged.
|
// available. This is a lossy transformation, unless the size is unchanged.
|
||||||
API int ncvisual_resize(struct ncvisual* n, int rows, int cols)
|
API int ncvisual_resize(struct ncvisual* n, int rows, int cols)
|
||||||
__attribute__ ((nonnull (1)));
|
__attribute__ ((nonnull (1)));
|
||||||
|
@ -106,7 +106,7 @@ ncvisual_blitset_geom(const notcurses* nc, const ncvisual* n,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(n){
|
if(n){
|
||||||
//fprintf(stderr, "OUR DATA: %p rows/cols: %d/%d\n", ncv->data, ncv->rows, ncv->cols);
|
//fprintf(stderr, "OUR DATA: %p rows/cols: %d/%d\n", n->data, n->rows, n->cols);
|
||||||
if(n->data == NULL){
|
if(n->data == NULL){
|
||||||
logerror(nc, "No data in visual\n");
|
logerror(nc, "No data in visual\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -906,7 +906,10 @@ int ncvisual_resize(ncvisual* nc, int rows, int cols){
|
|||||||
if(!visual_implementation){
|
if(!visual_implementation){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return visual_implementation->visual_resize(nc, rows, cols);
|
if(visual_implementation->visual_resize(nc, rows, cols)){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inflate each pixel of 'bmap' to 'scale'x'scale' pixels square, using the
|
// Inflate each pixel of 'bmap' to 'scale'x'scale' pixels square, using the
|
||||||
|
@ -51,7 +51,9 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
ncplane_erase(n);
|
ncplane_erase(n);
|
||||||
ncvisual_blitter_geom(nc, ncv, &vopts, nullptr, nullptr, &scaley, &scalex, nullptr);
|
ncvisual_blitter_geom(nc, ncv, &vopts, nullptr, nullptr, &scaley, &scalex, nullptr);
|
||||||
ncvisual_resize(ncv, dimy * scaley, dimx * scalex);
|
if(ncvisual_resize(ncv, dimy * scaley, dimx * scalex)){
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
vopts.n = n;
|
vopts.n = n;
|
||||||
if(ncvisual_render(nc, ncv, &vopts) == nullptr){
|
if(ncvisual_render(nc, ncv, &vopts) == nullptr){
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -50,7 +50,7 @@ TEST_CASE("Bitmaps") {
|
|||||||
.scaling = NCSCALE_NONE,
|
.scaling = NCSCALE_NONE,
|
||||||
.y = 0, .x = 0,
|
.y = 0, .x = 0,
|
||||||
.begy = 0, .begx = 0,
|
.begy = 0, .begx = 0,
|
||||||
.leny = y, .lenx = x,
|
.leny = 0, .lenx = 0,
|
||||||
.blitter = NCBLIT_PIXEL,
|
.blitter = NCBLIT_PIXEL,
|
||||||
.flags = NCVISUAL_OPTION_NODEGRADE,
|
.flags = NCVISUAL_OPTION_NODEGRADE,
|
||||||
.transcolor = 0,
|
.transcolor = 0,
|
||||||
@ -71,10 +71,11 @@ TEST_CASE("Bitmaps") {
|
|||||||
.flags = 0, .margin_b = 0, .margin_r = 0,
|
.flags = 0, .margin_b = 0, .margin_r = 0,
|
||||||
};
|
};
|
||||||
vopts.scaling = NCSCALE_SCALE;
|
vopts.scaling = NCSCALE_SCALE;
|
||||||
vopts.n = ncplane_create(n_, &nopts);
|
auto bigp = ncplane_create(n_, &nopts);
|
||||||
REQUIRE(vopts.n);
|
REQUIRE(bigp);
|
||||||
|
vopts.n = bigp;
|
||||||
uint64_t white = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
|
uint64_t white = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
|
||||||
ncplane_set_base(vopts.n, "x", 0, white);
|
ncplane_set_base(bigp, "x", 0, white);
|
||||||
CHECK(vopts.n == ncvisual_render(nc_, ncv, &vopts));
|
CHECK(vopts.n == ncvisual_render(nc_, ncv, &vopts));
|
||||||
CHECK(0 == notcurses_render(nc_));
|
CHECK(0 == notcurses_render(nc_));
|
||||||
CHECK(0 == ncvisual_inflate(ncv, 4));
|
CHECK(0 == ncvisual_inflate(ncv, 4));
|
||||||
@ -89,7 +90,18 @@ TEST_CASE("Bitmaps") {
|
|||||||
CHECK(4 == ncplane_dim_y(infn));
|
CHECK(4 == ncplane_dim_y(infn));
|
||||||
CHECK(4 == ncplane_dim_x(infn));
|
CHECK(4 == ncplane_dim_x(infn));
|
||||||
CHECK(0 == notcurses_render(nc_));
|
CHECK(0 == notcurses_render(nc_));
|
||||||
CHECK(0 == ncplane_destroy(vopts.n));
|
CHECK(0 == ncvisual_resize(ncv, 8, 8));
|
||||||
|
CHECK(ncv->rows == 8);
|
||||||
|
CHECK(ncv->cols == 8);
|
||||||
|
vopts.x = 11;
|
||||||
|
auto resizen = ncvisual_render(nc_, ncv, &vopts);
|
||||||
|
REQUIRE(resizen);
|
||||||
|
CHECK((8 + nc_->tcache.cellpixy - 1) / nc_->tcache.cellpixy == ncplane_dim_y(resizen));
|
||||||
|
CHECK((8 + nc_->tcache.cellpixx - 1) / nc_->tcache.cellpixx == ncplane_dim_x(resizen));
|
||||||
|
CHECK(0 == notcurses_render(nc_));
|
||||||
|
CHECK(0 == ncplane_destroy(bigp));
|
||||||
|
CHECK(0 == ncplane_destroy(resizen));
|
||||||
|
CHECK(0 == ncplane_destroy(infn));
|
||||||
CHECK(0 == ncplane_destroy(n));
|
CHECK(0 == ncplane_destroy(n));
|
||||||
ncvisual_destroy(ncv);
|
ncvisual_destroy(ncv);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user