mirror of
https://github.com/raysan5/raylib.git
synced 2026-09-02 20:33:35 +00:00
[rtextures] Fix GetPixelColor() reading the wrong bits for R5G5B5A1 blue (#6113)
R5G5B5A1 packs blue in bits 5..1 and alpha in bit 0, which is what SetPixelColor(), ImageFormat(), LoadImageColors() and GetImageColor() all do. GetPixelColor() masked bits 4..0 instead, so the decoded blue was the low four bits of blue shifted up with the alpha bit pulled in as its LSB. Packing r == g == b and decoding it back gave (164, 164, 74) for r=g=b=20; 31 of the 32 possible grey values decoded with unequal channels. ImageDrawImage() blends through GetPixelColor(), so drawing onto an R5G5B5A1 image was affected too. Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5333,7 +5333,7 @@ Color GetPixelColor(const void *srcPtr, int format)
|
||||
{
|
||||
color.r = (unsigned char)((((unsigned short *)srcPtr)[0] >> 11)*255/31);
|
||||
color.g = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 6) & 0b0000000000011111)*255/31);
|
||||
color.b = (unsigned char)((((unsigned short *)srcPtr)[0] & 0b0000000000011111)*255/31);
|
||||
color.b = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 1) & 0b0000000000011111)*255/31);
|
||||
color.a = (((unsigned short *)srcPtr)[0] & 0b0000000000000001)? 255 : 0;
|
||||
|
||||
} break;
|
||||
|
||||
Reference in New Issue
Block a user