彩票走势图

图像处理空间Aspose.Imaging v20.2全新功能上线!示例演示TIFF格式的不同栅格数据类型!

原创|产品更新|编辑:李显亮|2020-02-27 10:39:40.057|阅读 143 次

概述:在Aspose.Imaging for .NET v20.2中,支持TIFF格式的不同栅格数据类型,优化Tiff和Gif格式的速度或内存,添加矢量和多页图像的新类,修复多项格式转换时发生的异常,接下来我们用示例演示新增的功能。

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

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

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 loader
class 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 image
using (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 image
using (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引入矢量和多页图像的新类

  1. 引入了抽象类VectorImage。并且库中的所有矢量图像都从此类继承。位图图像是从RasterImage继承的。这样就可以唯一地分离光栅图像和矢量图像。
    using (Image image = Image.Load(fileName))  
    {  
     if (image is VectorImage)  
     {  
     ...  
     } 
     else 
     {  
     ...  
     }
    }
  2. 引入了IMultipageImage接口,借助它可以确定图像是否包含图层/页面/框架。所有多页图像(例如PSD,CDR,GIF等)都是该接口的后代。借助Pages属性,您可以访问库中任何多页图像的页面。
    using (Image image = Image.Load(fileName))  
    { 
     if (image is IMultipageImage) 
     {  
     var pages = ((IMultipageImage)image).Pages; 
     }  
    } 
  3. 有了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最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时,我们很高兴为您提供查询和咨询
标签:

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


为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP