#[cfg(test)]
mod color_conversion_tests {
use image::Rgba;
#[test]
fn test_rgba_to_argb_conversion() {
let rgba_pixel = Rgba([0xFF, 0x80, 0x40, 0xC0]);
let bgra_bytes = [
rgba_pixel[2], rgba_pixel[1], rgba_pixel[0], rgba_pixel[3], ];
assert_eq!(bgra_bytes[0], 0x40, "Blue should be first");
assert_eq!(bgra_bytes[1], 0x80, "Green should be second");
assert_eq!(bgra_bytes[2], 0xFF, "Red should be third");
assert_eq!(bgra_bytes[3], 0xC0, "Alpha should be fourth");
}
#[test]
fn test_color_red() {
let red_rgba = Rgba([255, 0, 0, 255]);
let bgra = [red_rgba[2], red_rgba[1], red_rgba[0], red_rgba[3]];
assert_eq!(bgra, [0, 0, 255, 255]);
}
#[test]
fn test_color_green() {
let green_rgba = Rgba([0, 255, 0, 255]);
let bgra = [green_rgba[2], green_rgba[1], green_rgba[0], green_rgba[3]];
assert_eq!(bgra, [0, 255, 0, 255]);
}
#[test]
fn test_color_blue() {
let blue_rgba = Rgba([0, 0, 255, 255]);
let bgra = [blue_rgba[2], blue_rgba[1], blue_rgba[0], blue_rgba[3]];
assert_eq!(bgra, [255, 0, 0, 255]);
}
#[test]
fn test_semi_transparent_color() {
let semi_rgba = Rgba([100, 150, 200, 128]); let bgra = [semi_rgba[2], semi_rgba[1], semi_rgba[0], semi_rgba[3]];
assert_eq!(bgra, [200, 150, 100, 128]);
}
}