Fix incorrect color transform to 255 space (#1297)

This commit is contained in:
Doyle 2020-07-06 04:02:32 +10:00 committed by GitHub
parent 6832da5aa7
commit 00fda3be65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3543,26 +3543,26 @@ Color GetPixelColor(void *srcPtr, int format)
case UNCOMPRESSED_GRAY_ALPHA: col = (Color){ ((unsigned char *)srcPtr)[0], ((unsigned char *)srcPtr)[0], ((unsigned char *)srcPtr)[0], ((unsigned char *)srcPtr)[1] }; break;
case UNCOMPRESSED_R5G6B5:
{
col.r = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 11)*31)/255);
col.g = (unsigned char)((((((unsigned short *)srcPtr)[0] >> 5) & 0b0000000000111111)*63)/255);
col.b = (unsigned char)(((((unsigned short *)srcPtr)[0] & 0b0000000000011111)*31)/255);
col.r = (unsigned char)((((unsigned short *)srcPtr)[0] >> 11)*255/31);
col.g = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 5) & 0b0000000000111111)*255/63);
col.b = (unsigned char)((((unsigned short *)srcPtr)[0] & 0b0000000000011111)*255/31);
col.a = 255;
} break;
case UNCOMPRESSED_R5G5B5A1:
{
col.r = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 11)*31)/255);
col.g = (unsigned char)((((((unsigned short *)srcPtr)[0] >> 6) & 0b0000000000011111)*31)/255);
col.b = (unsigned char)(((((unsigned short *)srcPtr)[0] & 0b0000000000011111)*31)/255);
col.r = (unsigned char)((((unsigned short *)srcPtr)[0] >> 11)*255/31);
col.g = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 6) & 0b0000000000011111)*255/31);
col.b = (unsigned char)((((unsigned short *)srcPtr)[0] & 0b0000000000011111)*255/31);
col.a = (((unsigned short *)srcPtr)[0] & 0b0000000000000001)? 255 : 0;
} break;
case UNCOMPRESSED_R4G4B4A4:
{
col.r = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 12)*15)/255);
col.g = (unsigned char)((((((unsigned short *)srcPtr)[0] >> 8) & 0b0000000000001111)*15)/255);
col.b = (unsigned char)((((((unsigned short *)srcPtr)[0] >> 4) & 0b0000000000001111)*15)/255);
col.a = (unsigned char)(((((unsigned short *)srcPtr)[0] & 0b0000000000001111)*15)/255);
col.r = (unsigned char)((((unsigned short *)srcPtr)[0] >> 12)*255/15);
col.g = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 8) & 0b0000000000001111)*255/15);
col.b = (unsigned char)(((((unsigned short *)srcPtr)[0] >> 4) & 0b0000000000001111)*255/15);
col.a = (unsigned char)((((unsigned short *)srcPtr)[0] & 0b0000000000001111)*255/15);
} break;
case UNCOMPRESSED_R8G8B8A8: col = (Color){ ((unsigned char *)srcPtr)[0], ((unsigned char *)srcPtr)[1], ((unsigned char *)srcPtr)[2], ((unsigned char *)srcPtr)[3] }; break;