mirror of
https://github.com/FranLMSP/snes.git
synced 2026-08-03 08:30:01 -04:00
rgb555 to rgb888 converter
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
pub fn rbg555_to_rgb888(rgb555: (u8, u8, u8)) -> (u8, u8, u8) {
|
||||
let red = rgb555.0 & 0b11111;
|
||||
let green = rgb555.1 & 0b11111;
|
||||
let blue = rgb555.2 & 0b11111;
|
||||
(
|
||||
(red << 3) | (red >> 2),
|
||||
(green << 3) | (green >> 2),
|
||||
(blue << 3) | (blue >> 2),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod color_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_rbg555_to_rgb888() {
|
||||
assert_eq!(rbg555_to_rgb888((0x00, 0x00, 0x00)), (0x00, 0x00, 0x00));
|
||||
assert_eq!(
|
||||
rbg555_to_rgb888((0b0001_1111, 0b0001_1111, 0b0001_1111)),
|
||||
(0xFF, 0xFF, 0xFF)
|
||||
);
|
||||
assert_eq!(
|
||||
rbg555_to_rgb888((0b10101, 0b01010, 0b11011)),
|
||||
(0xAD, 0x52, 0xDE)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod alu;
|
||||
pub mod addressing;
|
||||
pub mod num_trait;
|
||||
pub mod color;
|
||||
|
||||
Reference in New Issue
Block a user