Browse Source

Set HasTransparency to true, if tRns chunk is found. Fixes #2209

pull/2215/head
Brian Popow 4 years ago
parent
commit
0ee5e4382e
  1. 9
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

9
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Buffers; using System.Buffers;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -188,6 +187,7 @@ namespace SixLabors.ImageSharp.Formats.Png
chunk.Data.GetSpan().CopyTo(alpha); chunk.Data.GetSpan().CopyTo(alpha);
this.paletteAlpha = alpha; this.paletteAlpha = alpha;
this.AssignTransparentMarkers(alpha, pngMetadata); this.AssignTransparentMarkers(alpha, pngMetadata);
pngMetadata.HasTransparency = true;
break; break;
case PngChunkType.Text: case PngChunkType.Text:
this.ReadTextChunk(metadata, pngMetadata, chunk.Data.GetSpan()); this.ReadTextChunk(metadata, pngMetadata, chunk.Data.GetSpan());
@ -295,6 +295,7 @@ namespace SixLabors.ImageSharp.Formats.Png
chunk.Data.GetSpan().CopyTo(alpha); chunk.Data.GetSpan().CopyTo(alpha);
this.paletteAlpha = alpha; this.paletteAlpha = alpha;
this.AssignTransparentMarkers(alpha, pngMetadata); this.AssignTransparentMarkers(alpha, pngMetadata);
pngMetadata.HasTransparency = true;
if (this.colorMetadataOnly) if (this.colorMetadataOnly)
{ {
@ -380,8 +381,8 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary> /// <summary>
/// Reads the least significant bits from the byte pair with the others set to 0. /// Reads the least significant bits from the byte pair with the others set to 0.
/// </summary> /// </summary>
/// <param name="buffer">The source buffer</param> /// <param name="buffer">The source buffer.</param>
/// <param name="offset">THe offset</param> /// <param name="offset">THe offset.</param>
/// <returns>The <see cref="int"/></returns> /// <returns>The <see cref="int"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static byte ReadByteLittleEndian(ReadOnlySpan<byte> buffer, int offset) private static byte ReadByteLittleEndian(ReadOnlySpan<byte> buffer, int offset)
@ -392,7 +393,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// specified number of bits. /// specified number of bits.
/// </summary> /// </summary>
/// <param name="source">The bytes to convert from. Cannot be empty.</param> /// <param name="source">The bytes to convert from. Cannot be empty.</param>
/// <param name="bytesPerScanline">The number of bytes per scanline</param> /// <param name="bytesPerScanline">The number of bytes per scanline.</param>
/// <param name="bits">The number of bits per value.</param> /// <param name="bits">The number of bits per value.</param>
/// <param name="buffer">The new array.</param> /// <param name="buffer">The new array.</param>
/// <returns>The resulting <see cref="ReadOnlySpan{Byte}"/> array.</returns> /// <returns>The resulting <see cref="ReadOnlySpan{Byte}"/> array.</returns>

Loading…
Cancel
Save