Skip to content
0.2.0-dev Download ZIP
28 lines ·688 B Raw
1namespace EvilEngine.Formats.Textures;
2
3public static class TextureFile
4{
5 public const string Key = "EVIL_texture";
6
7 public static Texture Read(ReadOnlyMemory<byte> bytes, string file)
8 {
9 return Ktx2Reader.Read(bytes, file);
10 }
11
12 public static byte[] Write(Texture texture)
13 {
14 var ktx = Ktx2Writer.Write(texture);
15 if (!WrittenChecks.Enabled)
16 return ktx;
17 try
18 {
19 Ktx2Reader.Read(ktx, "written texture");
20 }
21 catch (TextureFormatException error)
22 {
23 throw new ArgumentException($"The texture wouldn't read back: {error.Message}", error);
24 }
25
26 return ktx;
27 }
28}