Skip to content

Commit ba5233b

Browse files
committed
Added ToArray to Image
1 parent 1782c83 commit ba5233b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ScreenCapture.NET/Model/Image.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public readonly ref struct Image<TColor>
3838
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3939
get
4040
{
41-
if ((x < 0) || (y < 0) || ((x + width) > Width) || ((y + height) > Height)) throw new IndexOutOfRangeException();
41+
if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0) || ((x + width) > Width) || ((y + height) > Height)) throw new IndexOutOfRangeException();
4242

4343
return new Image<TColor>(_pixels, _x + x, _y + y, width, height, _stride);
4444
}
@@ -87,6 +87,13 @@ public void CopyTo(in Span<TColor> dest)
8787
}
8888
}
8989

90+
public TColor[] ToArray()
91+
{
92+
TColor[] array = new TColor[Width * Height];
93+
CopyTo(array);
94+
return array;
95+
}
96+
9097
#endregion
9198

9299
#region Indexer-Structs

0 commit comments

Comments
 (0)