How do I get a vector of u8 RGB values when using the image crate?
问题 I need to take an image and get a list of RGB byte values. I am using the image crate. This is what I have: extern crate image; fn main() { let im = image::open("wall.jpg").unwrap().to_rgb(); let data: Vec<[u8; 3]> = im.pixels().flat_map(|p| vec![p.data]).collect(); let rgb: Vec<&u8> = data.iter().flat_map(|p| p.iter()).collect(); println!("First Pixel: {} {} {}", rgb[0], rgb[1], rgb[2]); } This seems pretty ugly. I have to introduce an intermediate variable and I get a vector of pointers to