@@ -225,7 +225,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
225
225
PngFrameMetadata pngFrameMetadata = currentFrame . Metadata . GetPngFrameMetadata ( ) ;
226
226
if ( previousFrame != null && pngFrameMetadata . BlendMethod == PngBlendMethod . Over )
227
227
{
228
- this . AlphaBlend ( previousFrame , currentFrame ) ;
228
+ this . AlphaBlend ( previousFrame , currentFrame , previousFrameControl . Value . Bounds ) ;
229
229
}
230
230
231
231
previousFrame = currentFrame ;
@@ -630,7 +630,7 @@ private void InitializeFrame<TPixel>(
630
630
if ( frameControl . DisposeOperation == PngDisposalMethod . Background
631
631
|| ( previousFrame is null && frameControl . DisposeOperation == PngDisposalMethod . Previous ) )
632
632
{
633
- Rectangle restoreArea = new ( ( int ) frameControl . XOffset , ( int ) frameControl . YOffset , ( int ) frameControl . Width , ( int ) frameControl . Height ) ;
633
+ Rectangle restoreArea = frameControl . Bounds ;
634
634
Rectangle interest = Rectangle . Intersect ( frame . Bounds ( ) , restoreArea ) ;
635
635
Buffer2DRegion < TPixel > pixelRegion = frame . PixelBuffer . GetRegion ( interest ) ;
636
636
pixelRegion . Clear ( ) ;
@@ -1895,15 +1895,15 @@ private static bool IsXmpTextData(ReadOnlySpan<byte> keywordBytes)
1895
1895
private void SwapScanlineBuffers ( )
1896
1896
=> ( this . scanline , this . previousScanline ) = ( this . previousScanline , this . scanline ) ;
1897
1897
1898
- private void AlphaBlend < TPixel > ( ImageFrame < TPixel > src , ImageFrame < TPixel > dst )
1898
+ private void AlphaBlend < TPixel > ( ImageFrame < TPixel > src , ImageFrame < TPixel > dst , Rectangle restoreArea )
1899
1899
where TPixel : unmanaged, IPixel < TPixel >
1900
1900
{
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 ) ;
1903
1903
PixelBlender < TPixel > blender =
1904
1904
PixelOperations < TPixel > . Instance . GetPixelBlender ( PixelColorBlendingMode . Normal , PixelAlphaCompositionMode . SrcOver ) ;
1905
1905
1906
- for ( int y = 0 ; y < src . Height ; y ++ )
1906
+ for ( int y = 0 ; y < srcPixels . Height ; y ++ )
1907
1907
{
1908
1908
Span < TPixel > srcPixelRow = srcPixels . DangerousGetRowSpan ( y ) ;
1909
1909
Span < TPixel > dstPixelRow = dstPixels . DangerousGetRowSpan ( y ) ;
0 commit comments