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();
for image in images {
add_image_to_tile_data(&mut tile_data, image, optimiser, 0)
for (image_idx, image) in images.iter().enumerate() {
add_image_to_tile_data(&mut tile_data, image, optimiser, image_idx)
}
let tile_data = collapse_to_4bpp(&tile_data);

View file

@ -138,17 +138,7 @@ impl Palette16Optimiser {
while !unsatisfied_palettes.is_empty() {
let palette = self.find_maximal_palette_for(&unsatisfied_palettes);
for test_palette in unsatisfied_palettes.clone() {
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();
}
}
unsatisfied_palettes.retain(|test_palette| !test_palette.is_satisfied_by(&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 {
optimised_palettes,
assignments,