~ TwoColor mode no longer needs a perfect white

This commit is contained in:
Johannes Theiner 2020-01-07 15:22:54 +01:00
parent 34388786e6
commit 6b49774838
2 changed files with 7 additions and 7 deletions

View File

@ -71,7 +71,7 @@ namespace vkvm {
case TwoColors: {
int pixelIndex = (y * getWidth() + x);
unsigned char *ptr = reinterpret_cast<unsigned char *>(getPixelArea()) + (pixelIndex / bitsPerPixel);
if (color == reg->foreground_color) {
if (color.getRed() > 127 || color.getGreen() > 127 || color.getBlue() > 127) {
//set bit to 1
ptr[0] |= (1 << (pixelIndex % bitsPerPixel));
} else {

View File

@ -31,9 +31,9 @@ TEST_CASE("Colors") {
vkvm::setMode(vkvm::TwoColors);
REQUIRE(vkvm::getPixel(10, 10) == vkvm::black);
REQUIRE(vkvm::getPixel(11, 11) == vkvm::white);
REQUIRE(vkvm::getPixel(12, 12) == vkvm::black);
REQUIRE(vkvm::getPixel(13, 13) == vkvm::black);
REQUIRE(vkvm::getPixel(14, 14) == vkvm::black);
REQUIRE(vkvm::getPixel(12, 12) == vkvm::white);
REQUIRE(vkvm::getPixel(13, 13) == vkvm::white);
REQUIRE(vkvm::getPixel(14, 14) == vkvm::white);
REQUIRE(vkvm::getPixel(15, 15) == vkvm::black);
REQUIRE(vkvm::getPixel(16, 16) == vkvm::white);
REQUIRE(vkvm::getPixel(17, 17) == vkvm::white);
@ -49,9 +49,9 @@ TEST_CASE("Colors") {
REQUIRE(vkvm::getPixel(10, 10) == vkvm::blue);
REQUIRE(vkvm::getPixel(11, 11) == vkvm::red);
REQUIRE(vkvm::getPixel(12, 12) == vkvm::blue);
REQUIRE(vkvm::getPixel(13, 13) == vkvm::blue);
REQUIRE(vkvm::getPixel(14, 14) == vkvm::blue);
REQUIRE(vkvm::getPixel(12, 12) == vkvm::red);
REQUIRE(vkvm::getPixel(13, 13) == vkvm::red);
REQUIRE(vkvm::getPixel(14, 14) == vkvm::red);
REQUIRE(vkvm::getPixel(15, 15) == vkvm::blue);
REQUIRE(vkvm::getPixel(16, 16) == vkvm::red);
REQUIRE(vkvm::getPixel(17, 17) == vkvm::red);