diff --git a/ScreenCapture.NET/Model/Image.cs b/ScreenCapture.NET/Model/Image.cs index a67ba53..f7ca9c8 100644 --- a/ScreenCapture.NET/Model/Image.cs +++ b/ScreenCapture.NET/Model/Image.cs @@ -38,7 +38,7 @@ public readonly ref struct Image [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - if ((x < 0) || (y < 0) || ((x + width) > Width) || ((y + height) > Height)) throw new IndexOutOfRangeException(); + if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0) || ((x + width) > Width) || ((y + height) > Height)) throw new IndexOutOfRangeException(); return new Image(_pixels, _x + x, _y + y, width, height, _stride); } @@ -87,6 +87,13 @@ public readonly ref struct Image } } + public TColor[] ToArray() + { + TColor[] array = new TColor[Width * Height]; + CopyTo(array); + return array; + } + #endregion #region Indexer-Structs