将每个布局导出为单独的 PNG 文件
Contents
[
Hide
]如何将每个布局导出为单独的 PNG 文件
问题: 如何将每个布局导出为单独的 PNG 文件。
提示: 要做到这一点,您只需遍历所有图层,并对每个图层执行保存方法。
示例:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CadImage cadImage = (CadImage)Image.Load(fileName); | |
var rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageSize = new SizeF(cadImage.Width, cadImage.Height); | |
CadLayoutDictionary layouts = cadImage.Layouts; | |
foreach (CadLayout layout in layouts.Values) | |
{ | |
rasterizationOptions.Layouts = new string[] { layout.LayoutName }; | |
ImageOptionsBase option = new PngOptions(); | |
option.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(layout.LayoutName + ".png", option); | |
} |