Check entire palette map

This commit is contained in:
Andrew 2022-11-29 16:59:33 +13:00
parent df34cdf5c5
commit 7f02f78c78

View file

@ -144,8 +144,7 @@ fn do_palette_reduction(png: &PngImage, palette_map: &[Option<u8>; 256]) -> Opti
} }
fn palette_map_to_byte_map(png: &PngImage, palette_map: &[Option<u8>; 256]) -> Option<[u8; 256]> { fn palette_map_to_byte_map(png: &PngImage, palette_map: &[Option<u8>; 256]) -> Option<[u8; 256]> {
let len = png.palette.as_ref().map_or(0, |p| p.len()); if (0..256).all(|i| palette_map[i].map_or(true, |to| to == i as u8)) {
if (0..len).all(|i| palette_map[i].map_or(true, |to| to == i as u8)) {
// No reduction necessary // No reduction necessary
return None; return None;
} }