parent
c36cc240e2
commit
4d62f9f7f9
4 changed files with 23 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
### Version 0.18.1 (unreleased)
|
||||
- Bump `rayon` to 0.9
|
||||
- Fix failure to optimize on certain grayscale images ([#89](https://github.com/shssoichiro/oxipng/issues/89))
|
||||
|
||||
### Version 0.18.0
|
||||
- Bump `itertools` to 0.7
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ pub fn reduce_bit_depth_8_or_less(png: &mut PngData) -> bool {
|
|||
for line in png.scan_lines() {
|
||||
let bit_vec = BitVec::from_bytes(&line.data);
|
||||
for (i, bit) in bit_vec.iter().enumerate() {
|
||||
let bit_index = bit_depth - (i % bit_depth);
|
||||
let bit_index = if png.ihdr_data.color_type == ColorType::Indexed {
|
||||
bit_depth - (i % bit_depth)
|
||||
} else {
|
||||
i % bit_depth
|
||||
};
|
||||
if bit && bit_index > allowed_bits {
|
||||
allowed_bits = bit_index.next_power_of_two();
|
||||
if allowed_bits == bit_depth {
|
||||
|
|
|
|||
BIN
tests/files/issue-89.png
Normal file
BIN
tests/files/issue-89.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 B |
|
|
@ -308,3 +308,20 @@ fn issue_82() {
|
|||
BitDepth::Four,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_89() {
|
||||
let input = PathBuf::from("tests/files/issue-89.png");
|
||||
let opts = get_opts(&input);
|
||||
let output = opts.out_file.clone();
|
||||
|
||||
test_it_converts(
|
||||
&input,
|
||||
&output,
|
||||
&opts,
|
||||
ColorType::RGBA,
|
||||
BitDepth::Eight,
|
||||
ColorType::Grayscale,
|
||||
BitDepth::Eight,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue