开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 3152|回复: 0

aspose.cad

[复制链接]

0

精华

0

贡献

0

赞扬

帖子
1
软币
57
在线时间
0 小时
注册时间
2017-2-15
发表于 2017-2-15 16:52:31 | 显示全部楼层 |阅读模式
在使用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);
                    }

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-5-7 15:27

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表