图像处理控件Aspose.Imaging v19.6新版亮点示例详解(2)

近期发布了Aspose.Imaging for .NET v19.6,JPEG输出中不再保留IMAGINGNET-3351 DPI属性,下面我们一起来探索新版中的新增功能及其工作原理。>>欢迎下载Aspose.Imaging for .NET v19.6体验

近期发布了Aspose.Imaging for .NET v19.6,JPEG输出中不再保留IMAGINGNET-3351 DPI属性,下面我们一起来探索新版中的新增功能及其工作原理。>>欢迎下载Aspose.Imaging for .NET v19.6体验

▲JPEG输出中不保留IMAGINGNET-3351 DPI属性

string dir = "c:\aspose.work\IMAGINGNET\3351\"; using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Load(dir + "source2.tif")){    int i = 0;    foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame tiffFrame in tiffImage.Frames)    {        Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();        saveOptions.ResolutionSettings = new ResolutionSetting(tiffFrame.HorizontalResolution, tiffFrame.VerticalResolution);         if (tiffFrame.FrameOptions != null)        {            // Set the resolution unit explicitly.            switch (tiffFrame.FrameOptions.ResolutionUnit)            {                case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.None:                    saveOptions.ResolutionUnit = ResolutionUnit.None;                    break;                 case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Inch:                    saveOptions.ResolutionUnit = ResolutionUnit.Inch;                    break;                 case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Centimeter:                    saveOptions.ResolutionUnit = ResolutionUnit.Cm;                    break;                 default:                    throw new System.NotSupportedException();            }        }         string fileName = "source2.tif.frame." + (i++) + "." + saveOptions.ResolutionUnit + ".jpg";        tiffFrame.Save(dir + fileName, saveOptions);    }}

▲IMAGINGNET-3321加载PNG图像时占用大量内存

using (Image image = Image.Load("halfGigImage.png")) {    // todo something}

▲IMAGINGNET-3287将WMF转换为SVG时会添加边距

string dir = "c:\aspose.work\IMAGINGNET\3287\";string fileName = dir + "image2.wmf"; // Save WMF to SVGusing (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName)){    // The customer uses EmfRasterizationOptions instead of WmfRasterizationOptions.    // EmfRasterizationOptions works correctly in .NET as well.    Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();    rasterizationOptions.PageSize = image.Size;     Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();    saveOptions.VectorRasterizationOptions = rasterizationOptions;     image.Save(fileName + ".svg", saveOptions);}                 // Save WMF to PNGusing (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName)){    // The customer uses EmfRasterizationOptions instead of WmfRasterizationOptions.    // EmfRasterizationOptions works correctly in .NET as well.    Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();    rasterizationOptions.PageSize = image.Size;     Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();    saveOptions.VectorRasterizationOptions = rasterizationOptions;     image.Save(fileName + ".png", saveOptions);}

▲IMAGINGNET-3378在将WMF转换为PNG时裁剪图像宽度和高度

public void WmfToJpg() {    using (Image image = Image.Load("portrt.wmf")) {        image.Save(                    "portrt.jpg",                    new JpegOptions()                        {                            VectorRasterizationOptions = new WmfRasterizationOptions                                                             {                                                                 BackgroundColor = Color.WhiteSmoke,                                                                 PageWidth = image.Width,                                                                 PageHeight = image.Height,                                                             }                        });    }} public void WmfToPngWithBorders() {    using (Image image = Image.Load("portrt.wmf")) {        image.Save(                    "portrt.png",                    new PngOptions()                        {                            VectorRasterizationOptions = new WmfRasterizationOptions                                                             {                                                                 BackgroundColor = Color.WhiteSmoke,                                                                 PageWidth = image.Width,                                                                 PageHeight = image.Height,                                                                 BorderX = 50,                                                                 BorderY = 20                                                             }                        });    }}

▲IMAGINGNET-3336使用ODG文件格式时,将在控制台中打印文本

string fileName = "example.odg";using (OdgImage image = (OdgImage)Image.Load(fileName)){}

▲IMAGINGNET-3421 GIF文件未正确转换为PDF

public void TestExportGifToPdf() {    string[] fileNames = new [] {        "czone.gif",        "DTRA_LogoType.gif",        "DTRA_Seal.gif",        "Equip1.gif",        "Equip2.gif",        "Equip3.gif"    };    foreach (string fileName in fileNames) {        using (Image image = Image.Load(fileName))        {            image.Save(fileName + ".pdf", new PdfOptions());        }    }}

▲IMAGINGNET-3205 RotateFlip操作与PSD无法正常工作

// RotateFlip operation doesn't work as expected with PSD            string sourceFile = "1.psd";            string pngPath = "RotateFlipTest2617.png";            string psdPath = "RotateFlipTest2617.psd";             RotateFlipType flipType = RotateFlipType.Rotate270FlipXY;            using (var im = (PsdImage)(Image.Load(sourceFile)))            {                im.RotateFlip(flipType);                im.Save(pngPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });                im.Save(psdPath);            }

▲IMAGINGNET-3374将DJVU格式转换为图像的问题

using (DjvuImage image = (DjvuImage)Imaging.Image.Load(@"input.djvu")){PngOptions exportOptions = new PngOptions();    for (int i = 0; i < image.Pages.Length; i++)    {        DjvuPage page = image.Pages[i];        page.Save(@"page" + i + ".png", exportOptions);    }}

▲IMAGINGNET-3339 SvgRasterizationOptions大小设置不起作用

using (Image image = Image.Load("test.svg")){    image.Save("test.svg_out.bmp",        new BmpOptions()        {            VectorRasterizationOptions = new SvgRasterizationOptions()            {                PageWidth = 100,                PageHeight = 200            }         });}

— 未完待续 —


*想要购买Aspose.Imaging正版授权的朋友可联系客服咨询哦~

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年6月19日
下一篇 2019年6月19日

相关推荐

发表回复

登录后才能评论