diff --git a/HPPH/Images/IImage.cs b/HPPH/Images/IImage.cs index bd5cac6..c1fcc61 100644 --- a/HPPH/Images/IImage.cs +++ b/HPPH/Images/IImage.cs @@ -73,7 +73,9 @@ public interface IImage : IEnumerable /// Allocates a new array and copies this into it. /// /// The new array containing the data of this . - byte[] ToArray(); + byte[] ToRawArray(); + + IColor[] ToArray(); /// /// Represents a list of rows of an image. diff --git a/HPPH/Images/Image.cs b/HPPH/Images/Image.cs index 3833d78..2bcb48a 100644 --- a/HPPH/Images/Image.cs +++ b/HPPH/Images/Image.cs @@ -109,13 +109,26 @@ public sealed class Image : IImage } /// - 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; + } + /// public RefImage AsRefImage() where T : struct, IColor