|
|
@ -12,7 +12,7 @@ TEST_CASE("Visual") {
|
|
|
|
|
|
|
|
|
|
|
|
// check that we properly populate RGB + A -> RGBA
|
|
|
|
// check that we properly populate RGB + A -> RGBA
|
|
|
|
SUBCASE("VisualFromRGBPacked") {
|
|
|
|
SUBCASE("VisualFromRGBPacked") {
|
|
|
|
unsigned char rgb[13] = "\x88\x77\x66\x55\x44\x33\x22\x11\x00\x99\xaa\xbb";
|
|
|
|
unsigned char rgb[] = "\x88\x77\x66\x55\x44\x33\x22\x11\x00\x99\xaa\xbb";
|
|
|
|
unsigned char alpha = 0xff;
|
|
|
|
unsigned char alpha = 0xff;
|
|
|
|
auto ncv = ncvisual_from_rgb_packed(rgb, 2, 6, 2, alpha);
|
|
|
|
auto ncv = ncvisual_from_rgb_packed(rgb, 2, 6, 2, alpha);
|
|
|
|
REQUIRE(nullptr != ncv);
|
|
|
|
REQUIRE(nullptr != ncv);
|
|
|
@ -20,7 +20,6 @@ TEST_CASE("Visual") {
|
|
|
|
for(int x = 0 ; x < 2 ; ++x){
|
|
|
|
for(int x = 0 ; x < 2 ; ++x){
|
|
|
|
uint32_t p;
|
|
|
|
uint32_t p;
|
|
|
|
CHECK(0 == ncvisual_at_yx(ncv, y, x, &p));
|
|
|
|
CHECK(0 == ncvisual_at_yx(ncv, y, x, &p));
|
|
|
|
fprintf(stderr, "rgba: 0x%02x 0x%02x 0x%02x 0x%02x\n", ncpixel_r(p), ncpixel_g(p), ncpixel_b(p), ncpixel_a(p));
|
|
|
|
|
|
|
|
CHECK(ncpixel_r(p) == rgb[y * 6 + x * 3]);
|
|
|
|
CHECK(ncpixel_r(p) == rgb[y * 6 + x * 3]);
|
|
|
|
CHECK(ncpixel_g(p) == rgb[y * 6 + x * 3 + 1]);
|
|
|
|
CHECK(ncpixel_g(p) == rgb[y * 6 + x * 3 + 1]);
|
|
|
|
CHECK(ncpixel_b(p) == rgb[y * 6 + x * 3 + 2]);
|
|
|
|
CHECK(ncpixel_b(p) == rgb[y * 6 + x * 3 + 2]);
|
|
|
@ -29,6 +28,24 @@ fprintf(stderr, "rgba: 0x%02x 0x%02x 0x%02x 0x%02x\n", ncpixel_r(p), ncpixel_g(p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check that we properly populate RGBx + A -> RGBA
|
|
|
|
|
|
|
|
SUBCASE("VisualFromRGBxPacked") {
|
|
|
|
|
|
|
|
unsigned char rgb[] = "\x88\x77\x66\x12\x55\x44\x33\x10\x22\x11\x00\xdd\x99\xaa\xbb\xcc";
|
|
|
|
|
|
|
|
unsigned char alpha = 0xff;
|
|
|
|
|
|
|
|
auto ncv = ncvisual_from_rgb_loose(rgb, 2, 8, 2, alpha);
|
|
|
|
|
|
|
|
REQUIRE(nullptr != ncv);
|
|
|
|
|
|
|
|
for(int y = 0 ; y < 2 ; ++y){
|
|
|
|
|
|
|
|
for(int x = 0 ; x < 2 ; ++x){
|
|
|
|
|
|
|
|
uint32_t p;
|
|
|
|
|
|
|
|
CHECK(0 == ncvisual_at_yx(ncv, y, x, &p));
|
|
|
|
|
|
|
|
CHECK(ncpixel_r(p) == rgb[y * 8 + x * 4]);
|
|
|
|
|
|
|
|
CHECK(ncpixel_g(p) == rgb[y * 8 + x * 4 + 1]);
|
|
|
|
|
|
|
|
CHECK(ncpixel_b(p) == rgb[y * 8 + x * 4 + 2]);
|
|
|
|
|
|
|
|
CHECK(ncpixel_a(p) == alpha);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check that NCVISUAL_OPTION_HORALIGNED works in all three cases
|
|
|
|
// check that NCVISUAL_OPTION_HORALIGNED works in all three cases
|
|
|
|
SUBCASE("VisualAligned") {
|
|
|
|
SUBCASE("VisualAligned") {
|
|
|
|
const uint32_t pixels[4] = { htole(0xffff0000), htole(0xff00ff00), htole(0xff0000ff), htole(0xffffffff) };
|
|
|
|
const uint32_t pixels[4] = { htole(0xffff0000), htole(0xff00ff00), htole(0xff0000ff), htole(0xffffffff) };
|
|
|
|