diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 93ded17f82..09653fd4cd 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -315,27 +315,13 @@ namespace SixLabors.ImageSharp.Formats.Webp { Buffer2D srcPixels = src.PixelBuffer; Buffer2D dstPixels = dst.PixelBuffer; - Rgba32 srcRgba = default; - Rgba32 dstRgba = default; - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.SrcOver); + PixelBlender blender = PixelOperations.Instance.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.SrcOver); for (int y = frameY; y < frameY + frameHeight; y++) { - Span srcPixelRow = srcPixels.DangerousGetRowSpan(y); - Span dstPixelRow = dstPixels.DangerousGetRowSpan(y); - for (int x = frameX; x < frameX + frameWidth; x++) - { - ref TPixel srcPixel = ref srcPixelRow[x]; - ref TPixel dstPixel = ref dstPixelRow[x]; - srcPixel.ToRgba32(ref srcRgba); - dstPixel.ToRgba32(ref dstRgba); - - if (srcRgba.A is not 0) - { - int dstFactorA = dstRgba.A * (255 - srcRgba.A) / 255; - Rgba32 blendResult = blender.Blend(srcRgba, dstRgba, 1.0f / dstFactorA); - dstPixel.FromRgba32(blendResult); - } - } + Span srcPixelRow = srcPixels.DangerousGetRowSpan(y).Slice(frameX, frameWidth); + Span dstPixelRow = dstPixels.DangerousGetRowSpan(y).Slice(frameX, frameWidth); + + blender.Blend(this.configuration, dstPixelRow, srcPixelRow, dstPixelRow, 1.0f); } }