From 7029b2ffb16fa6257b9ce2716fb02de540949c7a Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Thu, 13 May 2021 22:39:15 +0300 Subject: [PATCH] Image private property PixelSource no longer checks if object was disposed, check is delegated to public methods using that property --- src/ImageSharp/Image{TPixel}.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 4db3badb0..9c32a2c31 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp /// /// Gets the root frame. /// - private IPixelSource PixelSource => this.Frames?.RootFrame ?? throw new ObjectDisposedException(nameof(Image)); + private IPixelSource PixelSource => this.frames.RootFrame; /// /// Gets or sets the pixel at the specified position. @@ -174,6 +174,8 @@ namespace SixLabors.ImageSharp [MethodImpl(InliningOptions.ShortMethod)] get { + this.EnsureNotDisposed(); + this.VerifyCoords(x, y); return this.PixelSource.PixelBuffer.GetElementUnsafe(x, y); } @@ -181,6 +183,8 @@ namespace SixLabors.ImageSharp [MethodImpl(InliningOptions.ShortMethod)] set { + this.EnsureNotDisposed(); + this.VerifyCoords(x, y); this.PixelSource.PixelBuffer.GetElementUnsafe(x, y) = value; } @@ -198,6 +202,8 @@ namespace SixLabors.ImageSharp Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeLessThan(rowIndex, this.Height, nameof(rowIndex)); + this.EnsureNotDisposed(); + return this.PixelSource.PixelBuffer.GetRowSpan(rowIndex); }