Skip to content

Commit

Permalink
Add apng decode test
Browse files Browse the repository at this point in the history
  • Loading branch information
higumachan committed Sep 14, 2024
1 parent e14b4ac commit e39878f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/codecs/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,4 +760,22 @@ mod tests {
let mut target = Cursor::new(vec![]);
let _ = image.write_to(&mut target, ImageFormat::Png);
}

#[test]
fn apng_decode_partial_dispose() {
// Verify by comparing the APNG decode result with the final frame decoded by ffmpeg.

let apng = std::fs::read("tests/images/png/bugfixes/issue#2265.png").unwrap();

let last_frame_reference_image =
crate::open("tests/images/png/bugfixes/issue#2265_ffmpeg_decoded_last_frame.png")
.unwrap();

let decoder = PngDecoder::new(Cursor::new(&apng)).unwrap();
let decoder = decoder.apng().unwrap();
let frames = decoder.into_frames().collect::<Vec<_>>();
let last_frame = frames.last().as_ref().unwrap().as_ref().unwrap().buffer();

assert_eq!(last_frame_reference_image.to_rgba8(), last_frame.clone());
}
}
Binary file added tests/images/png/bugfixes/issue#2265.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e39878f

Please sign in to comment.