const WIDTH: usize = 900;
const HEIGHT: usize = 900;
struct Image {
width: usize,
height: usize,
buffer: Vec<u32>,
}
impl Image {
fn load(filename: &str) -> Image {
let image =
lodepng::decode32_file(&filename).expect(&format!("Couldn't load {}", &filename));
Image {
width: image.width,
height: image.height,
buffer: image
.buffer
.iter()
.map(|color| {
// println!("{:?}", color);
// Is --> Rgba { r: 188, g: 147, b: 129, a: 255 }
// Should be --> u32
let b = color.b;
let g = color.g;
let r = color.r;
let a = color.a;
let value = format!("{b}{g}{r}{a}");
// return 0x11223344;
return value as u32;
})
.collect(),
}
}
}
How can I concatenate the integer values and convert the string back to u32?