mirror of
https://github.com/DarthAffe/HPPH.git
synced 2025-12-13 05:48:57 +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.
|
/// Allocates a new array and copies this <see cref="IImage"/> into it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The new array containing the data of this <see cref="IImage"/>.</returns>
|
/// <returns>The new array containing the data of this <see cref="IImage"/>.</returns>
|
||||||
byte[] ToArray();
|
byte[] ToRawArray();
|
||||||
|
|
||||||
|
IColor[] ToArray();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a list of rows of an image.
|
/// Represents a list of rows of an image.
|
||||||
|
|||||||
@ -109,13 +109,26 @@ public sealed class Image<TColor> : IImage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public byte[] ToArray()
|
public byte[] ToRawArray()
|
||||||
{
|
{
|
||||||
byte[] array = new byte[SizeInBytes];
|
byte[] array = new byte[SizeInBytes];
|
||||||
CopyTo(array);
|
CopyTo(array);
|
||||||
return 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 />
|
/// <inheritdoc />
|
||||||
public RefImage<T> AsRefImage<T>()
|
public RefImage<T> AsRefImage<T>()
|
||||||
where T : struct, IColor
|
where T : struct, IColor
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user