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.