From bb6875b59bb23994e95068c0700f697d62d68429 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 27 Apr 2020 11:55:47 +0200 Subject: [PATCH] Write gamma chunk before palette --- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index fcbbc6697..34d5ee773 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -149,10 +149,10 @@ namespace SixLabors.ImageSharp.Formats.Png stream.Write(PngConstants.HeaderBytes); this.WriteHeaderChunk(stream); + this.WriteGammaChunk(stream); this.WritePaletteChunk(stream, quantized); this.WriteTransparencyChunk(stream, pngMetadata); this.WritePhysicalChunk(stream, metadata); - this.WriteGammaChunk(stream); this.WriteExifChunk(stream, metadata); this.WriteTextChunks(stream, pngMetadata); this.WriteDataChunks(image.Frames.RootFrame, quantized, stream); @@ -538,6 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the palette chunk to the stream. + /// Should be written before the first IDAT chunk. /// /// The pixel format. /// The containing image data. @@ -595,6 +596,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the physical dimension information to the stream. + /// Should be written before IDAT chunk. /// /// The containing image data. /// The image metadata. @@ -716,6 +718,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the gamma information to the stream. + /// Should be written before PLTE and IDAT chunk. /// /// The containing image data. private void WriteGammaChunk(Stream stream) @@ -733,6 +736,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the transparency chunk to the stream. + /// Should be written after PLTE and before IDAT. /// /// The containing image data. /// The image metadata.