fix image converter bug

This commit is contained in:
Corwin 2023-05-06 20:31:43 +01:00
parent 54340358bc
commit 26090499e7
No known key found for this signature in database
2 changed files with 10 additions and 13 deletions

View file

@ -432,8 +432,8 @@ fn palette_tile_data(
let mut tile_data = Vec::new(); let mut tile_data = Vec::new();
for image in images { for (image_idx, image) in images.iter().enumerate() {
add_image_to_tile_data(&mut tile_data, image, optimiser, 0) add_image_to_tile_data(&mut tile_data, image, optimiser, image_idx)
} }
let tile_data = collapse_to_4bpp(&tile_data); let tile_data = collapse_to_4bpp(&tile_data);

View file

@ -138,17 +138,7 @@ impl Palette16Optimiser {
while !unsatisfied_palettes.is_empty() { while !unsatisfied_palettes.is_empty() {
let palette = self.find_maximal_palette_for(&unsatisfied_palettes); let palette = self.find_maximal_palette_for(&unsatisfied_palettes);
for test_palette in unsatisfied_palettes.clone() { unsatisfied_palettes.retain(|test_palette| !test_palette.is_satisfied_by(&palette));
if test_palette.is_satisfied_by(&palette) {
unsatisfied_palettes.remove(&test_palette);
}
}
for (i, overall_palette) in self.palettes.iter().enumerate() {
if overall_palette.is_satisfied_by(&palette) {
assignments[i] = optimised_palettes.len();
}
}
optimised_palettes.push(palette); optimised_palettes.push(palette);
@ -157,6 +147,13 @@ impl Palette16Optimiser {
} }
} }
for (i, overall_palette) in self.palettes.iter().enumerate() {
assignments[i] = optimised_palettes
.iter()
.position(|palette| overall_palette.is_satisfied_by(palette))
.unwrap();
}
Palette16OptimisationResults { Palette16OptimisationResults {
optimised_palettes, optimised_palettes,
assignments, assignments,