From 3f8bd3d2e67913d2aa3500928dca44d6ed7fd35b Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Fri, 14 May 2021 03:20:03 +0300 Subject: [PATCH] Added internal accessor for root frame --- src/ImageSharp/ImageFrameCollection{TPixel}.cs | 9 +++++++++ src/ImageSharp/Image{TPixel}.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index c1eae0280..023da0d34 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -79,6 +79,15 @@ namespace SixLabors.ImageSharp } } + /// + /// Gets root frame accessor in unsafe manner without any checks. + /// + /// + /// This property is most likely to be called from for indexing pixels. + /// already checks if it was disposed before querying for root frame. + /// + internal ImageFrame RootFrameUnsafe => this.frames[0]; + /// protected override ImageFrame NonGenericRootFrame => this.RootFrame; diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 1fc77dc1f..3805446fe 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp /// /// Gets the root frame. /// - private IPixelSource PixelSource => this.frames.RootFrame; + private IPixelSource PixelSource => this.frames.RootFrameUnsafe; /// /// Gets or sets the pixel at the specified position.