Make sure correct bKGD is retained
This commit is contained in:
parent
181c6dd96f
commit
37161bf05d
1 changed files with 7 additions and 0 deletions
|
|
@ -76,6 +76,13 @@ pub fn reduced_palette(png: &PngImage) -> Option<PngImage> {
|
||||||
color_val(a.0).cmp(&color_val(b.0))
|
color_val(a.0).cmp(&color_val(b.0))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Make sure the background is also included, but only after sorting since it may not be used in idat
|
||||||
|
if let Some(&idx) = png.aux_headers.get(b"bKGD").and_then(|b| b.first()) {
|
||||||
|
if !used[idx as usize] {
|
||||||
|
used_enumerated.push((idx as usize, &true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut next_index = 0_u16;
|
let mut next_index = 0_u16;
|
||||||
let mut seen = IndexMap::with_capacity(palette.len());
|
let mut seen = IndexMap::with_capacity(palette.len());
|
||||||
for (i, used) in used_enumerated.iter().cloned() {
|
for (i, used) in used_enumerated.iter().cloned() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue