using Engine.Graphics.Pixel;
using Engine.Graphics.Texture;

namespace Engine.Asset;

public class Image<T> where T : struct, IPixel
{
  public int Width { get; }
  public int Height { get; }
  public T[,] Pixels { get; }

  public T this[int parY, int parX] => Pixels[parY, parX];

  public Image(int parWidth, int parHeight)
  {
    Width = parWidth;
    Height = parHeight;
    Pixels = new T[parHeight, parWidth];
  }

  public DynamicTexture ToDynamicTexture()
  {
    var texture = DynamicTexture.Create<T>(Width, Height);
    texture.UploadPixels(this);
    return texture;
  }

  public StaticTexture ToStaticTexture()
  {
    var texture = StaticTexture.Create<T>(Width, Height);
    texture.UploadPixels(this);
    return texture;
  }
}