public static void DdsToTxpAtlas(List <string> ddsFiles) { var atlas = new TxpTextureAtlas(); var serializer = new BinarySerializer(); foreach (var path in ddsFiles) { using (var ddsFile = new FileStream(path, FileMode.Open)) { var dds = serializer.Deserialize <DdsFile>(ddsFile); dds.SetMipMaps(); atlas.Textures.Add(dds.ToTxp()); } } atlas.TextureCount = atlas.Textures.Count; atlas.Textures.ForEach(tex => tex.SetMipOffsets()); atlas.SetTextureOffsets(); var savePath = ddsFiles[0].Length > 10 ? $"{ddsFiles[0].Slice(end: -10)}.txp" : Path.ChangeExtension(ddsFiles[0], "txp"); using (var txpFile = File.Create(savePath)) serializer.Serialize(txpFile, atlas); }
public void RoundtripTest() { var expected = new TxpTextureAtlas { Textures = new List <TxpTexture> { new TxpTexture { Mipmaps = new List <TxpMipmap> { new TxpMipmap() }, OffsetTable = new List <int> { 0 } } }, OffsetTable = new List <int> { 0 } }; var actual = Roundtrip(expected); }