Browse Source

Image<TPixel> private property PixelSource no longer checks if object was disposed, check is delegated to public methods using that property

pull/1629/head
Dmitry Pentin 5 years ago
parent
commit
7029b2ffb1
  1. 8
      src/ImageSharp/Image{TPixel}.cs

8
src/ImageSharp/Image{TPixel}.cs

@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp
/// <summary> /// <summary>
/// Gets the root frame. /// Gets the root frame.
/// </summary> /// </summary>
private IPixelSource<TPixel> PixelSource => this.Frames?.RootFrame ?? throw new ObjectDisposedException(nameof(Image<TPixel>)); private IPixelSource<TPixel> PixelSource => this.frames.RootFrame;
/// <summary> /// <summary>
/// Gets or sets the pixel at the specified position. /// Gets or sets the pixel at the specified position.
@ -174,6 +174,8 @@ namespace SixLabors.ImageSharp
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
get get
{ {
this.EnsureNotDisposed();
this.VerifyCoords(x, y); this.VerifyCoords(x, y);
return this.PixelSource.PixelBuffer.GetElementUnsafe(x, y); return this.PixelSource.PixelBuffer.GetElementUnsafe(x, y);
} }
@ -181,6 +183,8 @@ namespace SixLabors.ImageSharp
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
set set
{ {
this.EnsureNotDisposed();
this.VerifyCoords(x, y); this.VerifyCoords(x, y);
this.PixelSource.PixelBuffer.GetElementUnsafe(x, y) = value; this.PixelSource.PixelBuffer.GetElementUnsafe(x, y) = value;
} }
@ -198,6 +202,8 @@ namespace SixLabors.ImageSharp
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex)); Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
Guard.MustBeLessThan(rowIndex, this.Height, nameof(rowIndex)); Guard.MustBeLessThan(rowIndex, this.Height, nameof(rowIndex));
this.EnsureNotDisposed();
return this.PixelSource.PixelBuffer.GetRowSpan(rowIndex); return this.PixelSource.PixelBuffer.GetRowSpan(rowIndex);
} }

Loading…
Cancel
Save