public void extractTextureToPng(string outputFile, string packagePath, int exportID) { Package package = new Package(packagePath); Texture texture = new Texture(package, exportID, package.getExportData(exportID)); DDSFormat format = DDSImage.convertFormat(texture.properties.getProperty("Format").valueName); Texture.MipMap mipmap = texture.getTopMipmap(); byte[] data = texture.getTopImageData(); if (data == null) { MessageBox.Show("Failed to extract to PNG file. Broken game files!"); return; } PngBitmapEncoder image = DDSImage.ToPng(data, format, mipmap.width, mipmap.height); if (File.Exists(outputFile)) { File.Delete(outputFile); } using (FileStream fs = new FileStream(outputFile, FileMode.CreateNew, FileAccess.Write)) { image.Save(fs); } }