mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-12 13:28:37 +00:00
Added color-based ToArray to Image
This commit is contained in:
parent
1ec67c4d4b
commit
5242845a3e
@ -73,7 +73,9 @@ public interface IImage : IEnumerable<IColor>
|
||||
/// Allocates a new array and copies this <see cref="IImage"/> into it.
|
||||
/// </summary>
|
||||
/// <returns>The new array containing the data of this <see cref="IImage"/>.</returns>
|
||||
byte[] ToArray();
|
||||
byte[] ToRawArray();
|
||||
|
||||
IColor[] ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Represents a list of rows of an image.
|
||||
|
||||
@ -109,13 +109,26 @@ public sealed class Image<TColor> : IImage
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public byte[] ToArray()
|
||||
public byte[] ToRawArray()
|
||||
{
|
||||
byte[] array = new byte[SizeInBytes];
|
||||
CopyTo(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
//TODO DarthAffe 06.07.2024: This has some potential for optimization
|
||||
public IColor[] ToArray()
|
||||
{
|
||||
IColor[] colors = new IColor[Width * Height];
|
||||
|
||||
int counter = 0;
|
||||
foreach (IImage.IImageRow row in Rows)
|
||||
foreach (IColor color in row)
|
||||
colors[counter++] = color;
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public RefImage<T> AsRefImage<T>()
|
||||
where T : struct, IColor
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user