namespace HPPH.Test; internal static class TestDataHelper { public static T GetColorFromLocation(int x, int y) where T : struct, IColor { byte[] xBytes = BitConverter.GetBytes((short)x); byte[] yBytes = BitConverter.GetBytes((short)y); return (T)T.Create(xBytes[0], xBytes[1], yBytes[0], yBytes[1]); } public static T[] GetPixelData(int width, int height) where T : struct, IColor { T[] buffer = new T[width * height]; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) buffer[(y * width) + x] = GetColorFromLocation(x, y); return buffer; } public static Image CreateTestImage(int width, int height) where T : struct, IColor => Image.Create(GetPixelData(width, height), width, height); }