From 237c1f85ddf13b47330dd5f96f0881e2b843ff79 Mon Sep 17 00:00:00 2001 From: Dylan Pulver <35541198+dylanpulver@users.noreply.github.com> Date: Wed, 2 Sep 2026 10:42:19 +0300 Subject: [PATCH] [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 Co-authored-by: Claude --- src/rtextures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index e63077103..ac21b9514 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -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;