This commit is contained in:
Jay Oster 2019-11-03 16:58:58 -08:00
parent 0792d47ae7
commit 2d0b053cd7

View file

@ -81,11 +81,10 @@ fn load_pcx(pcx: &[u8]) -> CachedSprite {
// Copy to result with an alpha component // Copy to result with an alpha component
let pixels = buffer let pixels = buffer
.into_iter() .into_iter()
.map(|pal| { .flat_map(|pal| {
let i = pal as usize * 3; let i = pal as usize * 3;
&palette[i..i + 3] &palette[i..i + 3]
}) })
.flatten()
.cloned() .cloned()
.collect::<Vec<u8>>(); .collect::<Vec<u8>>();
result.extend_from_slice(&pixels); result.extend_from_slice(&pixels);
@ -99,12 +98,11 @@ fn load_pcx(pcx: &[u8]) -> CachedSprite {
// Copy to result with an alpha component // Copy to result with an alpha component
let pixels = buffer let pixels = buffer
.chunks(3) .chunks(3)
.map(|rgb| { .flat_map(|rgb| {
let mut rgb = rgb.to_vec(); let mut rgb = rgb.to_vec();
rgb.push(255); rgb.push(255);
rgb rgb
}) })
.flatten()
.collect::<Vec<u8>>(); .collect::<Vec<u8>>();
result.extend_from_slice(&pixels); result.extend_from_slice(&pixels);
} }