彩票走势图

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

翻译|产品更新|编辑:李显亮|2019-07-23 11:10:16.170|阅读 192 次

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

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

Aspose.Imaging for .NET一种高级图像处理控件,允许开发人员创建,编辑,绘制或转换图像。图像导出和转换是API核心功能之一,它允许在不安装Photoshop应用程序或任何其他图像编辑器的情况下保存为AdobePhotoshop®本机格式。

近期发布了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 SVG
using (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 PNG
using (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正版授权的朋友可咨询哦~

扫描关注慧聚IT微信公众号,及时获取最新动态及最新资讯

慧聚IT微信公众号



标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn

文章转载自:

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP