在Aspose.Imaging for .NET v20.2中,支持TIFF格式的不同栅格数据类型,优化Tiff和Gif格式的速度或内存,添加矢量和多页图像的新类,修复多项格式转换时发生的异常,接下来我们用示例演示新增的功能。
在Aspose.Imaging for .NET v20.2中,支持TIFF格式的不同栅格数据类型,优化Tiff和Gif格式的速度或内存,添加矢量和多页图像的新类,修复多项格式转换时发生的异常,接下来我们用示例演示新增的功能。
>>欢迎下载Aspose.Imaging for .NET v20.2体验
新增与改善
key
概述
类别
IMAGINGNET-3624
支持TIFF格式的不同栅格数据类型
功能
IMAGINGNET-3588
将TIFF转换为PNG的异常
功能
IMAGINGNET-3409
允许针对Tiff格式的速度或内存优化策略
功能
IMAGINGNET-3408
允许针对Gif格式的速度或内存优化策略
功能
IMAGINGNET-3364
统一处理多页图像导出
功能
IMAGINGNET-2548
介绍矢量和多页图像的新类
功能
IMAGINGNET-3633
将Tiff图片转换为PNG的异常
增强功能
IMAGINGNET-3632
将jpeg转换为pdf的异常
增强功能
IMAGINGNET-3631
将JPG转换为PDF时的异常
增强功能
IMAGINGNET-3623
QA 19.11 .NET 3549不透明零件
增强功能
新功能用法示例
IMAGINGNET-3624支持TIFF格式的不同栅格数据类型
示例一:根据其自身的原始数据格式加载原始数据。
// Raw data after decoding is processed to eliminate format-specific effects (prediction and invert color component values).using (RasterImage image = (RasterImage)Image.Load("input.tif")){image.LoadRawData(image.Bounds, image.RawDataSettings, new CustomRawDataLoader());}
示例二:根据用户指定的原始数据格式加载原始数据。
// In this case, in addition, raw data is converted from its own format to the one specified by the user.// Note that so far not all raw data formats can be converted to other formats (since not all color converters are still implemented and registered at the ColorConverterFactory).using (RasterImage image = (RasterImage)Image.Load("input.tif")){ RawDataSettings rawDataSettings = new RawDataSettings() { PixelDataFormat = PixelDataFormat.Rgb24Bpp, DitheringMethod = DitheringMethods.PaletteIgnore, }; rawDataSettings.LineSize = ((image.Width * rawDataSettings.PixelDataFormat.BitsPerPixel) + 7) / 8;image.LoadRawData(image.Bounds, image.RawDataSettings, new CustomRawDataLoader());}
示例三:加载未经处理的原始原始数据。
// Format-specific effects (prediction and invert color component values) may be present in this data, therefore this data cannot be used in color converters without pre-processing.using (RasterImage image = (RasterImage)Image.Load("input.tif")){image.LoadRawData(image.Bounds, null, new CustomRawDataLoader());}// Custom raw data loaderclass CustomRawDataLoader : IPartialRawDataLoader{ ////// Processes the loaded data. //////The data rectangle.///The raw data.///The start data point. If not equal to (left,top) meaning that it is not full rectangle we have.///The end data point. If not equal to (right,bottom) meaning that it is not full rectangle we have.public void Process(Rectangle rectangle, byte[] data, Point start, Point end) { this.Process(rectangle, data, start, end, null); } ////// Processes the loaded data. //////The data rectangle.///The raw data.///The start data point. If not equal to (left,top) meaning that it is not full rectangle we have.///The end data point. If not equal to (right,bottom) meaning that it is not full rectangle we have.///The load options.public void Process(Rectangle rectangle, byte[] data, Point start, Point end, LoadOptions loadOptions) { // custom raw data processing }}
IMAGINGNET-3623 QA 19.11 .NET 3549不透明零件
using (Image image = Image.Load("sample_car.svg")){ image.Resize(image.Width * 2, image.Height * 2); image.Save("sample_car_resize_2_2.png", new PngOptions());}
IMAGINGNET-3409允许对Tiff格式进行速度或内存优化的策略
// Setting a memory limit of 10 megabytes for target loaded imageusing (Image image = Image.Load("Default.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("Default_export.tiff", new TiffOptions(TiffExpectedFormat.Default));}using (Image image = Image.Load("TiffCcitRle.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("TiffCcitRle_export.tiff", new TiffOptions(TiffExpectedFormat.TiffCcitRle));}using (Image image = Image.Load("TiffDeflateRgb.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("TiffDeflateRgb_export.tiff", new TiffOptions(TiffExpectedFormat.TiffDeflateRgb));}using (Image image = Image.Load("TiffJpegYCbCr.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("TiffJpegYCbCr_export.tiff", new TiffOptions(TiffExpectedFormat.TiffJpegYCbCr));}using (Image image = Image.Load("TiffLzwCmyk.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("TiffLzwCmyk_export.tiff", new TiffOptions(TiffExpectedFormat.TiffLzwCmyk));}using (Image image = Image.Load("TiffNoCompressionRgb.tiff", new LoadOptions { BufferSizeHint = 10 })){ image.Save("TiffNoCompressionRgb_export.tiff", new TiffOptions(TiffExpectedFormat.TiffNoCompressionRgb));}
IMAGINGNET-3408允许Gif格式的速度或内存优化策略
// Setting a memory limit of 10 megabytes for target loaded imageusing (Image image = Image.Load("flowers.gif", new LoadOptions { BufferSizeHint = 10 })){ image.Save("flowers_export.gif", new GifOptions());}
IMAGINGNET-3364统一处理多页图像输出
string baseFolder = "D:\images";string outputFolderName = Path.Combine(baseFolder, "out");string[] files = new[] { "MultiframePage1.dicom", "VariousObjectsMultiPage.odg" };foreach (string inputFileName in files) { using (Image image = Image.Load(Path.Combine(baseFolder, inputFileName))) { PdfOptions imageOptions = new PdfOptions(); imageOptions.MultiPageOptions = new MultiPageOptions(new IntRange(1, 2)); if (image is VectorImage) { imageOptions.VectorRasterizationOptions = (VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Color.White, image.Width, image.Height }); imageOptions.VectorRasterizationOptions.TextRenderingHint = TextRenderingHint.SingleBitPerPixel; imageOptions.VectorRasterizationOptions.SmoothingMode = SmoothingMode.None; } string outFileName = Path.Combine(outputFolderName, inputFileName + ".pdf"); image.Save(outFileName, imageOptions); } }
IMAGINGNET-2548引入矢量和多页图像的新类
-
引入了抽象类VectorImage。并且库中的所有矢量图像都从此类继承。位图图像是从RasterImage继承的。这样就可以唯一地分离光栅图像和矢量图像。
using (Image image = Image.Load(fileName)) { if (image is VectorImage) { ... } else { ... }}
-
引入了IMultipageImage接口,借助它可以确定图像是否包含图层/页面/框架。所有多页图像(例如PSD,CDR,GIF等)都是该接口的后代。借助Pages属性,您可以访问库中任何多页图像的页面。
using (Image image = Image.Load(fileName)) { if (image is IMultipageImage) { var pages = ((IMultipageImage)image).Pages; } }
-
有了MultiPageOptions选项,导出多页图像变得更加容易。使用此选项,可以指定要导出为其他格式的页面。在导出为单页格式的情况下,将导出该范围的第一页;如果导出为多页面格式,则将导出该范围的所有页面。
从多页格式导出到单页的示例:int startPage = 3;int countPage = 2;using (Image image = Image.Load(fileName)){ PngOptions pngOptions = new PngOptions(); pngOptions.MultiPageOptions = new MultiPageOptions(new IntRange(startPage, countPage)); image.Save(outFileName, pngOptions);}
还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!