-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Hi, I was using this image converter and noticed that with test picture like this
color palette does not have pure white 0xFFFF but it has 0xFFF8. Question is that is this somehow intentional or a bug?
Here is the converter function and my proposed fix:
r=g=b=255
a = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b & 0xF8)
#fixed
b = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
print(f'{a:016b} != {b:016b}\n{a:2x} != {b:2x}')
# 1111111111111000 != 1111111111111111
# fff8 != ffff
st7789py_mpy/utils/image_converter.py
Lines 47 to 60 in 7265925
def rgb_to_color565(r, g, b): | |
""" | |
Convert RGB color to the 16-bit color format (565). | |
Args: | |
r (int): Red component of the RGB color (0-255). | |
g (int): Green component of the RGB color (0-255). | |
b (int): Blue component of the RGB color (0-255). | |
Returns: | |
int: Converted color value in the 16-bit color format (565). | |
""" | |
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b & 0xF8) |
Metadata
Metadata
Assignees
Labels
No labels