- 积分
- 0
- 在线时间
- 0 小时
- 主题
- 1
- 注册时间
- 2017-2-15
- 帖子
- 1
- 最后登录
- 2017-2-15
- 帖子
- 1
- 软币
- 57
- 在线时间
- 0 小时
- 注册时间
- 2017-2-15
|
在使用aspose.cad将cad文件转换为图片格式的时候,发现一些文件会转换成空白图片,还有一些转换过程中直接失败,请教各位大神谁能知道具体原因是什么,谢谢
以下是我转换的代码:
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(filePath))
{
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterOpts = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
var scaleType = Aspose.CAD.FileFormats.Cad.ScaleType.None;
var PageWidth = (float)image.Width;
var PageHeight = (float)image.Height;
if (image.Width > 50000 || image.Height > 50000)
{
if (image.Width > image.Height)
{
PageWidth = 50000;
PageHeight = (float)image.Height / (float)image.Width * 50000;
}
else
{
PageHeight = 50000;
PageWidth = (float)image.Width / (float)image.Height * 50000;
}
scaleType = Aspose.CAD.FileFormats.Cad.ScaleType.ShrinkToFit;
}
rasterOpts.PageHeight = PageHeight;
rasterOpts.PageWidth = PageWidth;
rasterOpts.ScaleMethod = scaleType;
rasterOpts.BackgroundColor = Aspose.CAD.Color.White;
rasterOpts.AutomaticLayoutsScaling = true;
rasterOpts.CenterDrawing = true;
rasterOpts.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor;
rasterOpts.TypeOfEntities = Aspose.CAD.ImageOptions.TypeOfEntities.Entities2D;
Aspose.CAD.ImageOptionsBase opts = new Aspose.CAD.ImageOptions.BmpOptions();
opts.VectorRasterizationOptions = rasterOpts;
image.Save(outputPath, opts);
}
|
|