namespace EvilEngine.Formats.Textures; public static class TextureFile { public const string Key = "EVIL_texture"; public static Texture Read(ReadOnlyMemory bytes, string file) { return Ktx2Reader.Read(bytes, file); } public static byte[] Write(Texture texture) { var ktx = Ktx2Writer.Write(texture); if (!WrittenChecks.Enabled) return ktx; try { Ktx2Reader.Read(ktx, "written texture"); } catch (TextureFormatException error) { throw new ArgumentException($"The texture wouldn't read back: {error.Message}", error); } return ktx; } }