Skip to content

Commit

Permalink
Keep fcTL after PLTE (#626)
Browse files Browse the repository at this point in the history
Fixes #625

---------

Co-authored-by: Alejandro González <[email protected]>
  • Loading branch information
andrews05 and AlexTMjugador authored Jun 22, 2024
1 parent 90ceef9 commit 3759ca8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/png/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ impl PngData {
// Ancillary chunks - split into those that come before IDAT and those that come after
let mut aux_split = self.aux_chunks.split(|c| &c.name == b"IDAT");
let aux_pre = aux_split.next().unwrap();
// Many chunks need to be before PLTE, so write all except those that explicitly need to be after
// Note: the PNG spec does not say that fcTL needs to be after PLTE, but some decoders expect
// that (see issue #625)
for chunk in aux_pre
.iter()
.filter(|c| !(&c.name == b"bKGD" || &c.name == b"hIST" || &c.name == b"tRNS"))
.filter(|c| !matches!(&c.name, b"bKGD" | b"hIST" | b"tRNS" | b"fcTL"))
{
write_png_block(&chunk.name, &chunk.data, &mut output);
}
Expand Down Expand Up @@ -223,7 +226,7 @@ impl PngData {
// Special ancillary chunks that need to come after PLTE but before IDAT
for chunk in aux_pre
.iter()
.filter(|c| &c.name == b"bKGD" || &c.name == b"hIST" || &c.name == b"tRNS")
.filter(|c| matches!(&c.name, b"bKGD" | b"hIST" | b"tRNS" | b"fcTL"))
{
write_png_block(&chunk.name, &chunk.data, &mut output);
}
Expand Down

0 comments on commit 3759ca8

Please sign in to comment.