Added ToArray to Image

This commit is contained in:
Darth Affe 2023-09-05 20:20:25 +02:00
parent 1782c83415
commit ba5233be6f

View File

@ -38,7 +38,7 @@ public readonly ref struct Image<TColor>
[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<TColor>(_pixels, _x + x, _y + y, width, height, _stride);
}
@ -87,6 +87,13 @@ public readonly ref struct Image<TColor>
}
}
public TColor[] ToArray()
{
TColor[] array = new TColor[Width * Height];
CopyTo(array);
return array;
}
#endregion
#region Indexer-Structs