mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed black/white threshold computation for Unix monochrome cursors
This commit is contained in:
parent
d93cd6dd30
commit
9cb67520c7
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user