awesome-bits icon indicating copy to clipboard operation
awesome-bits copied to clipboard

Color conversoin seems wrong

Open jrmuizel opened this issue 8 years ago • 1 comments

Fast color conversion from R5G5B5 to R8G8B8 pixel format using shifts

R8 = (R5 << 3) | (R5 >> 2) G8 = (R5 << 3) | (R5 >> 2) B8 = (R5 << 3) | (R5 >> 2)

This looks to assign the same value to R8, G8 and B8

jrmuizel avatar Dec 22 '16 03:12 jrmuizel

In 16 bits: x16 must be uint16
R16 = R5 & 0xF800;
G16 = (R5 & 0x7E0) << 5;
B16 = R5 << 11; // Make sure to be uint16_t 

In 8 bits: R5 must be uint16
R8 = (R5 >> 11) << 3;
G8 = (R5 & 0x7E0) >> 3;
B8 = (R5 & 0x1F) << 3; 

X-Ryl669 avatar Nov 29 '21 14:11 X-Ryl669