目录
  1. 1. 背景
  2. 2. 基础代码
  3. 3. 软件界面
  4. 4. 软件下载
Enscape全景图保存

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"; // 指定的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

文章作者: 嗜血星空earth
文章链接: http://sxxkearth.github.io/2025/01/26/Enscape%E5%85%A8%E6%99%AF%E5%9B%BE%E4%BF%9D%E5%AD%98/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请附以署名及出处!

评论