ncvisual_inflate: call ncvisual_seed_details() #1546

pull/1567/head
nick black 3 years ago
parent 8209bc6841
commit 7d61457b37
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -936,9 +936,10 @@ int ncvisual_inflate(ncvisual* n, int scale){
if(inflaton == NULL){ if(inflaton == NULL){
return -1; return -1;
} }
ncvisual_set_data(n, inflaton, true);
n->rows *= scale; n->rows *= scale;
n->cols *= scale; n->cols *= scale;
n->rowstride = 4 * n->cols; n->rowstride = 4 * n->cols;
ncvisual_set_data(n, inflaton, true); ncvisual_details_seed(n);
return 0; return 0;
} }

@ -467,7 +467,7 @@ int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const int targformat = AV_PIX_FMT_RGBA; const int targformat = AV_PIX_FMT_RGBA;
//fprintf(stderr, "got format: %d want format: %d\n", inframe->format, targformat); //fprintf(stderr, "got format: %d want format: %d\n", inframe->format, targformat);
if(inframe && (cols != inframe->width || rows != inframe->height || inframe->format != targformat)){ if(inframe && (cols != inframe->width || rows != inframe->height || inframe->format != targformat)){
//fprintf(stderr, "resize+render: %d/%d->%d/%d (%dX%d @ %dX%d, %d/%d)\n", inframe->height, inframe->width, rows, cols, begy, begx, placey, placex, leny, lenx); //fprintf(stderr, "resize+render: %d/%d->%d/%d (%d/%d)\n", inframe->height, inframe->width, rows, cols, leny, lenx);
sframe = av_frame_alloc(); sframe = av_frame_alloc();
if(sframe == NULL){ if(sframe == NULL){
//fprintf(stderr, "Couldn't allocate output frame for scaled frame\n"); //fprintf(stderr, "Couldn't allocate output frame for scaled frame\n");

@ -36,9 +36,21 @@ TEST_CASE("Visual") {
} }
SUBCASE("InflateBitmap") { SUBCASE("InflateBitmap") {
const uint32_t pixels[4] = { htole(0xffff0000), htole(0xff00ff00), htole(0xff0000ff), htole(0xffffffff) }; const uint32_t pixels[4] = { htole(0xffff00ff), htole(0xff00ffff), htole(0xff0000ff), htole(0xffffffff) };
auto ncv = ncvisual_from_rgba(pixels, 2, 8, 2); auto ncv = ncvisual_from_rgba(pixels, 2, 8, 2);
REQUIRE(ncv); REQUIRE(ncv);
ncvisual_options vopts = {
.n = nullptr,
.scaling = NCSCALE_NONE,
.y = 0, .x = 0,
.begy = 0, .begx = 0,
.leny = 0, .lenx = 0,
.blitter = NCBLIT_1x1,
.flags = 0, .transcolor = 0,
};
auto newn = ncvisual_render(nc_, ncv, &vopts);
CHECK(0 == notcurses_render(nc_));
sleep(2);
CHECK(0 == ncvisual_inflate(ncv, 3)); CHECK(0 == ncvisual_inflate(ncv, 3));
CHECK(6 == ncv->rows); CHECK(6 == ncv->rows);
CHECK(6 == ncv->cols); CHECK(6 == ncv->cols);
@ -58,23 +70,16 @@ TEST_CASE("Visual") {
CHECK(pixels[3] == ncv->data[y * ncv->cols + x]); CHECK(pixels[3] == ncv->data[y * ncv->cols + x]);
} }
} }
ncvisual_options vopts = {
.n = nullptr,
.scaling = NCSCALE_NONE,
.y = 0, .x = 0,
.begy = 0, .begx = 0,
.leny = 0, .lenx = 0,
.blitter = NCBLIT_1x1,
.flags = 0, .transcolor = 0,
};
auto newn = ncvisual_render(nc_, ncv, &vopts);
REQUIRE(newn); REQUIRE(newn);
auto enewn = ncvisual_render(nc_, ncv, &vopts);
int newy, newx; int newy, newx;
ncplane_dim_yx(newn, &newy, &newx); ncplane_dim_yx(enewn, &newy, &newx);
CHECK(6 == newy); CHECK(6 == newy);
CHECK(6 == newx); CHECK(6 == newx);
CHECK(0 == ncplane_destroy(newn));
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_destroy(newn));
CHECK(0 == ncplane_destroy(enewn));
sleep(2);
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
} }
@ -552,14 +557,18 @@ TEST_CASE("Visual") {
ncplane_dim_yx(ncp_, &dimy, &dimx); ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("changes.jpg")); auto ncv = ncvisual_from_file(find_data("changes.jpg"));
REQUIRE(ncv); REQUIRE(ncv);
/*CHECK(dimy * 2 == frame->height); int odimy, odimx, ndimy, ndimx;
CHECK(dimx == frame->width); FIXME */
struct ncvisual_options opts{}; struct ncvisual_options opts{};
opts.scaling = NCSCALE_STRETCH;
opts.n = ncp_; opts.n = ncp_;
CHECK(0 == ncvisual_blitter_geom(nc_, ncv, &opts, &odimy, &odimx, nullptr, nullptr, nullptr));
CHECK(ncvisual_render(nc_, ncv, &opts));
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncvisual_inflate(ncv, 2));
CHECK(0 == ncvisual_blitter_geom(nc_, ncv, &opts, &ndimy, &ndimx, nullptr, nullptr, nullptr));
CHECK(ndimy == odimy * 2);
CHECK(ndimx == odimx * 2);
CHECK(ncvisual_render(nc_, ncv, &opts)); CHECK(ncvisual_render(nc_, ncv, &opts));
CHECK(0 == notcurses_render(nc_)); CHECK(0 == notcurses_render(nc_));
CHECK(1 == ncvisual_decode(ncv));
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
} }

Loading…
Cancel
Save