From 74d8be625631f46e7af1777c7e71fa8180db70b3 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 7 Nov 2021 16:35:43 +0100 Subject: [PATCH] fix warning & simplify ClearTransparentPixels --- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 4645f22e31..5e067aba57 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -163,11 +163,11 @@ namespace SixLabors.ImageSharp.Formats.Png /// The type of the pixel. /// The cloned image where the transparent pixels will be changed. private static void ClearTransparentPixels(Image image) - where TPixel : unmanaged, IPixel - { + where TPixel : unmanaged, IPixel => image.ProcessPixelRows(accessor => { Rgba32 rgba32 = default; + Rgba32 transparent = Color.Transparent; for (int y = 0; y < accessor.Height; y++) { Span span = accessor.GetRowSpan(y); @@ -177,14 +177,12 @@ namespace SixLabors.ImageSharp.Formats.Png if (rgba32.A == 0) { - span[x].FromRgba32(Color.Transparent); + span[x].FromRgba32(transparent); } } } }); - } - /// /// Creates the quantized image and sets calculates and sets the bit depth. ///