@@ -225,7 +225,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
225225 PngFrameMetadata pngFrameMetadata = currentFrame . Metadata . GetPngFrameMetadata ( ) ;
226226 if ( previousFrame != null && pngFrameMetadata . BlendMethod == PngBlendMethod . Over )
227227 {
228- this . AlphaBlend ( previousFrame , currentFrame ) ;
228+ this . AlphaBlend ( previousFrame , currentFrame , previousFrameControl . Value . Bounds ) ;
229229 }
230230
231231 previousFrame = currentFrame ;
@@ -630,7 +630,7 @@ private void InitializeFrame<TPixel>(
630630 if ( frameControl . DisposeOperation == PngDisposalMethod . Background
631631 || ( previousFrame is null && frameControl . DisposeOperation == PngDisposalMethod . Previous ) )
632632 {
633- Rectangle restoreArea = new ( ( int ) frameControl . XOffset , ( int ) frameControl . YOffset , ( int ) frameControl . Width , ( int ) frameControl . Height ) ;
633+ Rectangle restoreArea = frameControl . Bounds ;
634634 Rectangle interest = Rectangle . Intersect ( frame . Bounds ( ) , restoreArea ) ;
635635 Buffer2DRegion < TPixel > pixelRegion = frame . PixelBuffer . GetRegion ( interest ) ;
636636 pixelRegion . Clear ( ) ;
@@ -1895,15 +1895,15 @@ private static bool IsXmpTextData(ReadOnlySpan<byte> keywordBytes)
18951895 private void SwapScanlineBuffers ( )
18961896 => ( this . scanline , this . previousScanline ) = ( this . previousScanline , this . scanline ) ;
18971897
1898- private void AlphaBlend < TPixel > ( ImageFrame < TPixel > src , ImageFrame < TPixel > dst )
1898+ private void AlphaBlend < TPixel > ( ImageFrame < TPixel > src , ImageFrame < TPixel > dst , Rectangle restoreArea )
18991899 where TPixel : unmanaged, IPixel < TPixel >
19001900 {
1901- Buffer2D < TPixel > srcPixels = src . PixelBuffer ;
1902- Buffer2D < TPixel > dstPixels = dst . PixelBuffer ;
1901+ Buffer2DRegion < TPixel > srcPixels = src . PixelBuffer . GetRegion ( restoreArea ) ;
1902+ Buffer2DRegion < TPixel > dstPixels = dst . PixelBuffer . GetRegion ( restoreArea ) ;
19031903 PixelBlender < TPixel > blender =
19041904 PixelOperations < TPixel > . Instance . GetPixelBlender ( PixelColorBlendingMode . Normal , PixelAlphaCompositionMode . SrcOver ) ;
19051905
1906- for ( int y = 0 ; y < src . Height ; y ++ )
1906+ for ( int y = 0 ; y < srcPixels . Height ; y ++ )
19071907 {
19081908 Span < TPixel > srcPixelRow = srcPixels . DangerousGetRowSpan ( y ) ;
19091909 Span < TPixel > dstPixelRow = dstPixels . DangerousGetRowSpan ( y ) ;
0 commit comments