Enterprise Architect API 用于将图像添加到图像管理器
Enterprise Architect API for Adding Image to Image Manager
我正在 Enterprise Architect C# 加载项中处理表单。我需要通过自动化将图像添加到图像管理器,因为通过在 element/package 注释中设置指向它们的超链接,我可以使用 EA API Repository.ExtractImagesFromNote () 将图像导出到外部路径。
在常用工具箱中,有一个图像元素。在拖放时,它会自动打开图像管理器以为其设置备用图像。我还注意到这个图像没有显示在项目浏览器中(是因为它是一个非 UML 元素吗?)。
我尝试通过自动化添加此图像元素,如下所示:
EA.Element testImg = viewPkg.Elements.AddNew(imagePath, "Image")
创建的元素如图所示:
它创建了一个图像资产(来自工件工具箱)而不是图像元素(来自通用工具箱)。
我需要将图像添加到图像管理器。我请求帮助从通用工具箱创建图像元素并通过代码而不是图像资产为其设置图像。
我在图像管理器中也注意到了这个选项:
当前更新代码 t_image table:
string base64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(@"C:\Users\Desktop\Figure 1.1.bmp"));
Session.Repository.Execute("INSERT INTO t_image VALUES('0000000002','test200','Bitmap','"+base64+ "')");
我更新了下面的代码,用于将 .png 中的图像转换为 base64 编码的字符串
var imageStream = new MemoryStream();
Bitmap resized = new Bitmap(img, new Size(img.Width / 5, img.Height / 5));
resized.Save(imageStream, ImageFormat.Png);
imageStream.Position = 0;
var imageBytes = imageStream.ToArray();
ImageBase64 = Convert.ToBase64String(imageBytes, 0, imageBytes.Length);
我正在使用 repository.execute 命令将此值插入 t_image table:
Session.Repository.Execute("INSERT INTO t_image VALUES(" + imgCount + ",'" + imgPath+".bmp" + "','Bitmap','"+ImageBase64+"')");
实际上是创建一个 <<image>> Artifact
(或者您可以使用 Boundary
)并为其分配备用图像。图片需要放在EA的图片库中。您可以阅读 如何实现。
我正在 Enterprise Architect C# 加载项中处理表单。我需要通过自动化将图像添加到图像管理器,因为通过在 element/package 注释中设置指向它们的超链接,我可以使用 EA API Repository.ExtractImagesFromNote () 将图像导出到外部路径。
在常用工具箱中,有一个图像元素。在拖放时,它会自动打开图像管理器以为其设置备用图像。我还注意到这个图像没有显示在项目浏览器中(是因为它是一个非 UML 元素吗?)。
我尝试通过自动化添加此图像元素,如下所示:
EA.Element testImg = viewPkg.Elements.AddNew(imagePath, "Image")
创建的元素如图所示:
它创建了一个图像资产(来自工件工具箱)而不是图像元素(来自通用工具箱)。
我需要将图像添加到图像管理器。我请求帮助从通用工具箱创建图像元素并通过代码而不是图像资产为其设置图像。
我在图像管理器中也注意到了这个选项:
当前更新代码 t_image table:
string base64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(@"C:\Users\Desktop\Figure 1.1.bmp"));
Session.Repository.Execute("INSERT INTO t_image VALUES('0000000002','test200','Bitmap','"+base64+ "')");
我更新了下面的代码,用于将 .png 中的图像转换为 base64 编码的字符串
var imageStream = new MemoryStream();
Bitmap resized = new Bitmap(img, new Size(img.Width / 5, img.Height / 5));
resized.Save(imageStream, ImageFormat.Png);
imageStream.Position = 0;
var imageBytes = imageStream.ToArray();
ImageBase64 = Convert.ToBase64String(imageBytes, 0, imageBytes.Length);
我正在使用 repository.execute 命令将此值插入 t_image table:
Session.Repository.Execute("INSERT INTO t_image VALUES(" + imgCount + ",'" + imgPath+".bmp" + "','Bitmap','"+ImageBase64+"')");
实际上是创建一个 <<image>> Artifact
(或者您可以使用 Boundary
)并为其分配备用图像。图片需要放在EA的图片库中。您可以阅读