From d73c12be6f888e011dd74878dc3bcf2abde7e27e Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 5 Jun 2020 02:31:36 -0400 Subject: [PATCH] ncvisual_from_plane: argument inversion error #678 --- src/lib/notcurses.c | 2 ++ src/lib/visual.cpp | 3 ++- tests/rotate.cpp | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 8b50018f8..5717b241d 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1957,9 +1957,11 @@ uint32_t* ncplane_rgba(const ncplane* nc, int begy, int begx, int leny, int lenx if(lenx < 0 || leny < 0){ // no need to draw zero-size object, exit return NULL; } +//fprintf(stderr, "sum: %d/%d avail: %d/%d\n", begy + leny, begx + lenx, nc->leny, nc->lenx); if(begx + lenx > nc->lenx || begy + leny > nc->leny){ return NULL; } +//fprintf(stderr, "ALLOCATING %zu\n", 4u * lenx * leny * 2); uint32_t* ret = malloc(sizeof(*ret) * lenx * leny * 2); if(ret){ for(int y = begy, targy = 0 ; y < begy + leny ; ++y, targy += 2){ diff --git a/src/lib/visual.cpp b/src/lib/visual.cpp index f1c225295..68c09df50 100644 --- a/src/lib/visual.cpp +++ b/src/lib/visual.cpp @@ -475,7 +475,8 @@ auto ncvisual_render(notcurses* nc, ncvisual* ncv, auto ncvisual_from_plane(const ncplane* n, int begy, int begx, int leny, int lenx) -> ncvisual* { - uint32_t* rgba = ncplane_rgba(n, begx, begy, leny, lenx); + uint32_t* rgba = ncplane_rgba(n, begy, begx, leny, lenx); +//fprintf(stderr, "snarg: %d/%d @ %d/%d (%p)\n", leny, lenx, begy, begx, rgba); if(rgba == nullptr){ return nullptr; } diff --git a/tests/rotate.cpp b/tests/rotate.cpp index ca8d5ad74..8e7100308 100644 --- a/tests/rotate.cpp +++ b/tests/rotate.cpp @@ -1,7 +1,6 @@ #include "main.h" #include #include -#include void RotateCW(struct notcurses* nc, struct ncplane* n) { CHECK(0 == notcurses_render(nc)); @@ -124,7 +123,7 @@ TEST_CASE("Rotate") { REQUIRE(rgbaret); for(int i = 0 ; i < height * width / 2 ; ++i){ if(rgbaret[i] & CELL_BG_MASK){ - CHECK(rgbaret[i] == htonl(rgba[i])); + CHECK(rgbaret[i] == rgba[i]); } } free(rgbaret); @@ -175,7 +174,7 @@ TEST_CASE("Rotate") { REQUIRE(rgbaret); for(int i = 0 ; i < height * width / 2 ; ++i){ if(rgbaret[i] & CELL_BG_MASK){ - CHECK(rgbaret[i] == htonl(rgba[i])); + CHECK(rgbaret[i] == rgba[i]); } } free(rgbaret);