Browse Source

Fix indexed png alpha selection. Fix #163 #165

pull/167/head
James Jackson-South 9 years ago
parent
commit
a7b878d8d2
  1. 9
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  2. 1
      src/ImageSharp/Quantizers/QuantizedImage.cs

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

@ -516,9 +516,14 @@ namespace ImageSharp.Formats
colorTable[offset + 1] = bytes[1];
colorTable[offset + 2] = bytes[2];
if (alpha <= this.options.Threshold)
if (alpha < 255 && alpha <= this.options.Threshold)
{
transparentPixels.Add((byte)offset);
// Ensure the index is actually being used in our array.
// I'd like to find a faster way of doing this.
if (quantized.Pixels.Contains((byte)i))
{
transparentPixels.Add((byte)i);
}
}
}

1
src/ImageSharp/Quantizers/QuantizedImage.cs

@ -6,7 +6,6 @@
namespace ImageSharp.Quantizers
{
using System;
using System.Threading.Tasks;
/// <summary>
/// Represents a quantized image where the pixels indexed by a color palette.

Loading…
Cancel
Save