Files
doom-dm/Engine/Asset/Image.cs
2024-12-04 22:35:04 +03:00

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;
}
}