ncpixel_set_g/ncpixel_set_b: correct #1080

This commit is contained in:
nick black 2020-10-30 03:50:47 -04:00
parent 0f5f4cd1c3
commit e12cfe947b
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 8 additions and 8 deletions

View File

@ -2457,7 +2457,7 @@ ncpixel_set_g(uint32_t* pixel, int g){
if(g > 255 || g < 0){
return -1;
}
*pixel = (*pixel & 0xff00fffful) | (g << 16u);
*pixel = (*pixel & 0xffff00fful) | (g << 8u);
return 0;
}
@ -2467,7 +2467,7 @@ ncpixel_set_b(uint32_t* pixel, int b){
if(b > 255 || b < 0){
return -1;
}
*pixel = (*pixel & 0xffff00fful) | (b << 8u);
*pixel = (*pixel & 0xff00fffful) | (b << 16u);
return 0;
}

View File

@ -279,13 +279,13 @@ TEST_CASE("Visual") {
for(int i = 0 ; i < DIMY * DIMX ; ++i){
CHECK(0 == ncpixel_set_a(&rgba[i], 0xff));
if(i % 2){
CHECK(0 == ncpixel_set_g(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_b(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_r(&rgba[i], 0));
}else{
CHECK(0 == ncpixel_set_r(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_g(&rgba[i], 0));
CHECK(0 == ncpixel_set_b(&rgba[i], 0));
}
CHECK(0 == ncpixel_set_b(&rgba[i], 0));
CHECK(0 == ncpixel_set_g(&rgba[i], 0));
}
auto ncv = ncvisual_from_rgba(rgba, DIMY, DIMX * sizeof(uint32_t), DIMX);
REQUIRE(nullptr != ncv);
@ -319,11 +319,11 @@ TEST_CASE("Visual") {
for(int i = 0 ; i < DIMY * DIMX ; ++i){
CHECK(0 == ncpixel_set_a(&rgba[i], 0xff));
if(i % 2){
CHECK(0 == ncpixel_set_g(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_b(&rgba[i], 0));
}else{
CHECK(0 == ncpixel_set_b(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_g(&rgba[i], 0));
}else{
CHECK(0 == ncpixel_set_g(&rgba[i], 0xff));
CHECK(0 == ncpixel_set_b(&rgba[i], 0));
}
CHECK(0 == ncpixel_set_r(&rgba[i], 0));
}