Browse Source

Fixed transparency update

pull/1012/head
Peter Tribe 7 years ago
parent
commit
f8c5277fb4
  1. 10
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

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

@ -155,19 +155,17 @@ namespace SixLabors.ImageSharp.Formats.Png
using (Image<TPixel> tempImage = image.Clone()) using (Image<TPixel> tempImage = image.Clone())
{ {
Span<TPixel> span = tempImage.GetPixelSpan(); Span<TPixel> span = tempImage.GetPixelSpan();
foreach (TPixel pixel in span) for (int i = 0; i < span.Length; i++)
{ {
Rgba32 rgba32 = Rgba32.Transparent; Rgba32 rgba32 = default;
pixel.ToRgba32(ref rgba32); span[i].ToRgba32(ref rgba32);
if (rgba32.A == 0) if (rgba32.A == 0)
{ {
rgba32.R = 0; rgba32.R = 0;
rgba32.G = 0; rgba32.G = 0;
rgba32.B = 0; rgba32.B = 0;
} }
span[i].FromRgba32(rgba32);
pixel.FromRgba32(rgba32);
} }
quantized = PngEncoderOptionsHelpers.CreateQuantizedFrame(this.options, tempImage); quantized = PngEncoderOptionsHelpers.CreateQuantizedFrame(this.options, tempImage);

Loading…
Cancel
Save