Browse Source

fix warning & simplify ClearTransparentPixels

af/UniformUnmanagedMemoryPoolMemoryAllocator-02-MemoryGuards
Anton Firszov 5 years ago
parent
commit
74d8be6256
  1. 8
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

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

@ -163,11 +163,11 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <typeparam name="TPixel">The type of the pixel.</typeparam> /// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="image">The cloned image where the transparent pixels will be changed.</param> /// <param name="image">The cloned image where the transparent pixels will be changed.</param>
private static void ClearTransparentPixels<TPixel>(Image<TPixel> image) private static void ClearTransparentPixels<TPixel>(Image<TPixel> image)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel> =>
{
image.ProcessPixelRows(accessor => image.ProcessPixelRows(accessor =>
{ {
Rgba32 rgba32 = default; Rgba32 rgba32 = default;
Rgba32 transparent = Color.Transparent;
for (int y = 0; y < accessor.Height; y++) for (int y = 0; y < accessor.Height; y++)
{ {
Span<TPixel> span = accessor.GetRowSpan(y); Span<TPixel> span = accessor.GetRowSpan(y);
@ -177,14 +177,12 @@ namespace SixLabors.ImageSharp.Formats.Png
if (rgba32.A == 0) if (rgba32.A == 0)
{ {
span[x].FromRgba32(Color.Transparent); span[x].FromRgba32(transparent);
} }
} }
} }
}); });
}
/// <summary> /// <summary>
/// Creates the quantized image and sets calculates and sets the bit depth. /// Creates the quantized image and sets calculates and sets the bit depth.
/// </summary> /// </summary>

Loading…
Cancel
Save