Fix unfiltering of first scan line in each pass of an interlaced input file
Closes #92
This commit is contained in:
parent
833611ba2f
commit
f8c62de6c0
4 changed files with 46 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
### Version 0.18.2 (unreleased)
|
### Version 0.18.2 (unreleased)
|
||||||
- Bump `image` to 0.18
|
- Bump `image` to 0.18
|
||||||
|
- Fix unfiltering of scan lines in interlaced images ([#92](https://github.com/shssoichiro/oxipng/issues/92))
|
||||||
|
|
||||||
### Version 0.18.1
|
### Version 0.18.1
|
||||||
- Bump `rayon` to 0.9
|
- Bump `rayon` to 0.9
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,14 @@ impl PngData {
|
||||||
8f32)
|
8f32)
|
||||||
.ceil() as usize;
|
.ceil() as usize;
|
||||||
let mut last_line: Vec<u8> = Vec::new();
|
let mut last_line: Vec<u8> = Vec::new();
|
||||||
|
let mut last_pass = 1;
|
||||||
for line in self.scan_lines() {
|
for line in self.scan_lines() {
|
||||||
|
if let Some(pass) = line.pass {
|
||||||
|
if pass != last_pass {
|
||||||
|
last_line = Vec::new();
|
||||||
|
last_pass = pass;
|
||||||
|
}
|
||||||
|
}
|
||||||
let unfiltered_line = unfilter_line(line.filter, bpp, &line.data, &last_line);
|
let unfiltered_line = unfilter_line(line.filter, bpp, &line.data, &last_line);
|
||||||
unfiltered.push(0);
|
unfiltered.push(0);
|
||||||
unfiltered.extend_from_slice(&unfiltered_line);
|
unfiltered.extend_from_slice(&unfiltered_line);
|
||||||
|
|
|
||||||
BIN
tests/files/issue-92.png
Normal file
BIN
tests/files/issue-92.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -325,3 +325,41 @@ fn issue_89() {
|
||||||
BitDepth::Eight,
|
BitDepth::Eight,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_92_filter_0() {
|
||||||
|
let input = PathBuf::from("tests/files/issue-92.png");
|
||||||
|
let opts = get_opts(&input);
|
||||||
|
let output = opts.out_file.clone();
|
||||||
|
|
||||||
|
test_it_converts(
|
||||||
|
&input,
|
||||||
|
&output,
|
||||||
|
&opts,
|
||||||
|
ColorType::Grayscale,
|
||||||
|
BitDepth::Eight,
|
||||||
|
ColorType::Grayscale,
|
||||||
|
BitDepth::Eight,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_92_filter_5() {
|
||||||
|
let input = PathBuf::from("tests/files/issue-92.png");
|
||||||
|
let mut opts = get_opts(&input);
|
||||||
|
let mut filter = HashSet::new();
|
||||||
|
filter.insert(5);
|
||||||
|
opts.filter = filter;
|
||||||
|
opts.out_file = input.with_extension("-f5-out.png").to_owned();
|
||||||
|
let output = opts.out_file.clone();
|
||||||
|
|
||||||
|
test_it_converts(
|
||||||
|
&input,
|
||||||
|
&output,
|
||||||
|
&opts,
|
||||||
|
ColorType::Grayscale,
|
||||||
|
BitDepth::Eight,
|
||||||
|
ColorType::Grayscale,
|
||||||
|
BitDepth::Eight,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue