From 0ee5e4382e00593ca7fb01f80f7ed643e1f5198d Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 24 Aug 2022 22:28:04 +0200 Subject: [PATCH] Set HasTransparency to true, if tRns chunk is found. Fixes #2209 --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 784d9aa11..8e6789132 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -4,7 +4,6 @@ using System; using System.Buffers; using System.Buffers.Binary; -using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Runtime.CompilerServices; @@ -188,6 +187,7 @@ namespace SixLabors.ImageSharp.Formats.Png chunk.Data.GetSpan().CopyTo(alpha); this.paletteAlpha = alpha; this.AssignTransparentMarkers(alpha, pngMetadata); + pngMetadata.HasTransparency = true; break; case PngChunkType.Text: this.ReadTextChunk(metadata, pngMetadata, chunk.Data.GetSpan()); @@ -295,6 +295,7 @@ namespace SixLabors.ImageSharp.Formats.Png chunk.Data.GetSpan().CopyTo(alpha); this.paletteAlpha = alpha; this.AssignTransparentMarkers(alpha, pngMetadata); + pngMetadata.HasTransparency = true; if (this.colorMetadataOnly) { @@ -380,8 +381,8 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Reads the least significant bits from the byte pair with the others set to 0. /// - /// The source buffer - /// THe offset + /// The source buffer. + /// THe offset. /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] private static byte ReadByteLittleEndian(ReadOnlySpan buffer, int offset) @@ -392,7 +393,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// specified number of bits. /// /// The bytes to convert from. Cannot be empty. - /// The number of bytes per scanline + /// The number of bytes per scanline. /// The number of bits per value. /// The new array. /// The resulting array.