32 lines
796 B
C#
32 lines
796 B
C#
using Engine.Renderer.Pixel;
|
|
using Engine.Renderer.Texture;
|
|
|
|
namespace Engine.Asset;
|
|
|
|
public class Image<T>(T[,] pixels)
|
|
where T : struct, IPixel
|
|
{
|
|
public int Width { get; } = pixels.GetLength(0);
|
|
public int Height { get; } = pixels.GetLength(1);
|
|
public T[,] Pixels { get; } = pixels;
|
|
|
|
public T this[int x, int y] => Pixels[x, y];
|
|
|
|
public Image(int width, int height) : this(new T[width, height])
|
|
{
|
|
}
|
|
|
|
public DynamicTexture<T> ToDynamicTexture()
|
|
{
|
|
var texture = new DynamicTexture<T>(Width, Height);
|
|
texture.UploadPixels(this);
|
|
return texture;
|
|
}
|
|
|
|
public StaticTexture<T> ToStaticTexture()
|
|
{
|
|
var texture = new StaticTexture<T>(Width, Height);
|
|
texture.UploadPixels(this);
|
|
return texture;
|
|
}
|
|
} |