Skip to content

Commit

Permalink
fix for panic formatting imageset where there's only one colour in th…
Browse files Browse the repository at this point in the history
…e source tile
  • Loading branch information
yeastplume committed Feb 26, 2020
1 parent 6dcc324 commit 6010ab5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vera/src/imageset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,9 @@ fn find_optimal_range(
if max - min <= range as usize {
for i in 0..permutation.len() {
range_vals[i].1 = vec![usize::from_str_radix(permutation[i], 10)?];
if max == min {
break;
}
}
return Ok((true, min));
}
Expand Down
23 changes: 23 additions & 0 deletions vera/tests/imageset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,26 @@ fn imageset_pal_64_4bpp() -> Result<(), Error> {

Ok(())
}

/*#[test]
fn imageset_crash() -> Result<(), Error> {
let test_png = include_bytes!("data/imageset/crash-test-pal.png");
let pal_config = VeraPaletteLoadConfig {
direct_load: true,
include_defaults: false,
sort: false,
..VeraPaletteLoadConfig::default()
};
let palette = VeraPalette::derive_from_png("pal", test_png.to_vec(), &pal_config)?;
println!("{}", palette);
let imageset_png = include_bytes!("data/imageset/crash-test-imageset.png");
let mut set = VeraImageSet::new("imageset_1", 16, 16);
let config = VeraImageSetLoadConfig::default();
set.load_from_png(imageset_png.to_vec(), &config)?;
set.format_indices(&palette, VeraPixelDepth::BPP4)?;
println!("{}", set);
Ok(())
}*/

0 comments on commit 6010ab5

Please sign in to comment.