fix color555 to 888 conversion

This commit is contained in:
alice pellerin
2026-05-16 15:55:26 -05:00
parent b721091c3c
commit 906a152a21
+4 -5
View File
@@ -949,11 +949,10 @@ const fn is_illegal_control_character(character: char) -> bool {
} }
} }
const fn color555_to_color888(color555: u16) -> [u8; 3] { fn color555_to_color888(color555: u16) -> [u8; 3] {
[ [
// 8 is the ratio between the number of colors in 555 vs 888 (32:256) (u8::try_from((color555 & 0b11111) * 255 / 31).unwrap()),
(color555 & 0b11111) as u8 * 8, (u8::try_from((color555 >> 5 & 0b11111) * 255 / 31).unwrap()),
(color555 >> 5 & 0b11111) as u8 * 8, (u8::try_from((color555 >> 10 & 0b11111) * 255 / 31).unwrap())
(color555 >> 10 & 0b11111) as u8 * 8
] ]
} }