using Engine.Asset; using Engine.Graphics.Pixel; namespace Engine.Graphics.Texture; public interface IConstTexture { public int Width { get; } public int Height { get; } public void ReadPixels(int parX, int parY, int parWidth, int parHeight, T[,] parPixels) where T : struct, IPixel; } public static class ConstTextureExtensions { public static T[,] ReadPixels(this IConstTexture parTexture) where T : struct, IPixel { return parTexture.ReadPixels(0, 0, parTexture.Width, parTexture.Height); } public static T[,] ReadPixels(this IConstTexture parTexture, int parX, int parY, int parWidth, int parHeight) where T : struct, IPixel { var pixels = new T[parWidth, parHeight]; parTexture.ReadPixels(parX, parY, parWidth, parHeight, pixels); return pixels; } public static void ReadPixels(this IConstTexture parTexture, Image parImage) where T : struct, IPixel { parTexture.ReadPixels(0, 0, parImage); } public static void ReadPixels(this IConstTexture parTexture, int parX, int parY, Image parImage) where T : struct, IPixel { parTexture.ReadPixels(parX, parY, parImage.Width, parImage.Height, parImage.Pixels); } public static void ReadPixels(this IConstTexture parTexture, T[,] parPixels) where T : struct, IPixel { parTexture.ReadPixels(0, 0, parTexture.Width, parTexture.Height, parPixels); } }