static void ConvertTXS3Texture(string path) { if (!_texConvChecked && !File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "texconv.exe"))) { Console.WriteLine("TexConv (image to DDS tool) is missing. Download it from https://github.com/microsoft/DirectXTex/releases and place it next to the tool."); return; } _texConvChecked = true; _texConvExists = true; var texSet = new TextureSet3(); texSet.FromFile(path); Console.WriteLine($"Found: {texSet.Textures.Count} texture(s)"); string dir = Path.GetDirectoryName(path); for (int i = 0; i < texSet.Textures.Count; i++) { var texture = texSet.Textures[i]; Console.WriteLine($"Format: {texture.Format} - {texture.Width}x{texture.Height} ({texture.Mipmap} mipmaps)"); if (string.IsNullOrEmpty(texture.Name)) { if (texSet.Textures.Count == 1) { texture.Name = Path.GetFileNameWithoutExtension(path); } else { texture.Name = Path.GetFileNameWithoutExtension(path) + $"_{i}"; } } else { Console.WriteLine($"Texture Name: {texture.Name}"); } texture.SaveAsPng(dir); } Console.WriteLine($"Converted {currentFileName} to png."); }
public static void TexConvImg(TexConvImgOptions option) { TXS3ImageFormat format = option.Format switch { "DXT1" => TXS3ImageFormat.DXT1, "DXT3" => TXS3ImageFormat.DXT3, "DXT5" => TXS3ImageFormat.DXT5, "DXT10" => TXS3ImageFormat.DXT10, }; if (format == TXS3ImageFormat.Unknown) { Console.WriteLine("Wrong format. Expected DXT1/DXT3/DXT5/DXT10."); return; } foreach (var file in option.InputFiles) { if (!File.Exists(file)) { Console.WriteLine($"File '{file}' does not exist."); continue; } TextureSet3 texSet = new TextureSet3(); texSet.WriteNames = option.WriteNames; texSet.LittleEndian = option.LittleEndian; if (texSet.AddFromStandardImage(file, format)) { texSet.ConvertToTXS(Path.ChangeExtension(file, ".img")); Console.WriteLine($"Converted {file} to TXS3."); } else { Console.WriteLine($"Could not process {file}."); } } }