Fix RGB565 and RGB5A3 not being bright enough when decoded
@@ -67,9 +67,9 @@ def convert_rgb565_to_color(rgb565):
r = ((rgb565 >> 11) & 0x1F)
g = ((rgb565 >> 5) & 0x3F)
b = ((rgb565 >> 0) & 0x1F)
- r = r << 3
- g = g << 2
- b = b << 3
+ r = r*255//0x1F
+ g = g*255//0x3F
+ b = b*255//0x1F
return (r, g, b, 255)
def convert_color_to_rgb565(color):
@@ -94,18 +94,18 @@ def convert_rgb5a3_to_color(rgb5a3):
r = ((rgb5a3 >> 8) & 0xF)
g = ((rgb5a3 >> 4) & 0xF)
b = ((rgb5a3 >> 0) & 0xF)
- a = a << 5
- r = r << 4
- g = g << 4
- b = b << 4
+ a = a*255//7
+ r = r*255//0xF
+ g = g*255//0xF
+ b = b*255//0xF
else:
a = 255
r = ((rgb5a3 >> 10) & 0x1F)
g = ((rgb5a3 >> 5) & 0x1F)
b = ((rgb5a3 >> 0) & 0x1F)
- r = r << 3
- g = g << 3
- b = b << 3
+ r = r*255//0x1F
+ g = g*255//0x1F
+ b = b*255//0x1F
return (r, g, b, a)
def convert_color_to_rgb5a3(color):
