Enscape输出的全景图在上传前被保存在XML数据文件中,本文描述从改XML文件中提取出完整全景图的方法;
背景
![导出位置]()
Revit
软件中,使用Enscape
输出全景图后本地文件中并未见到新生成的照片,通过对电脑中文件进行检索,发现在C:\Users\Administrator\Documents\Enscape\Panoramas
路径下,新生成了一个panorama_1.xml
文件;通过使用Xml Viewer对该文件进行查看发现全景图照片照片数据是以Base64
编码的形式存储在该XML文件的<ImageContent>
标签中;在此基础上,制作工具对照片进行提取;
![xml文件]()
基础代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| using System; using System.IO; using System.Xml;
class Program { static void Main(string[] args) { string xmlFilePath = @"C:\Users\earth\Documents\Enscape\Panoramas\panorama_1.xml"; string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); ExtractPhotosFromXml(xmlFilePath, desktopPath); }
static void ExtractPhotosFromXml(string xmlFilePath, string outputDirectory) { using (XmlReader reader = XmlReader.Create(xmlFilePath)) { int photoIndex = 1; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "ImageContent") { string base64Data = reader.ReadElementContentAsString(); byte[] photoData = Convert.FromBase64String(base64Data);
string photoFilePath = Path.Combine(outputDirectory, $"photo_{photoIndex}.png"); File.WriteAllBytes(photoFilePath, photoData); Console.WriteLine($"提取并保存照片 {photoIndex} 到 {photoFilePath}");
photoIndex++; } } } } }
|
软件界面
通过选择XML文件进行图片保存,保存文件位于xml源位置;
![界面]()
软件下载
软件下载:Enscape全景图提取XmlToPhoto.exe