Fixed black/white threshold computation for Unix monochrome cursors

This commit is contained in:
Corentin Schreiber 2020-08-21 09:58:20 +01:00 committed by Lukas Dürrenberger
parent d93cd6dd30
commit 9cb67520c7

View File

@ -123,9 +123,9 @@ bool CursorImpl::loadFromPixelsMonochrome(const Uint8* pixels, Vector2u size, Ve
// Choose between black/background & white/foreground color for each pixel,
// based on the pixel color intensity: on average, if a channel is "active"
// at 25%, the bit is white.
int intensity = pixels[pixelIndex * 4 + 0] + pixels[pixelIndex * 4 + 1] + pixels[pixelIndex * 4 + 2];
Uint8 bit = intensity > 64 ? 1 : 0;
// at 50%, the bit is white.
int intensity = (pixels[pixelIndex * 4 + 0] + pixels[pixelIndex * 4 + 1] + pixels[pixelIndex * 4 + 2]) / 3;
Uint8 bit = intensity > 128 ? 1 : 0;
data[byteIndex] |= bit << bitIndex;
}
}