原創|產品更新|編輯:李顯亮|2020-02-27 10:39:40.057|閱讀 168 次
概述:在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不透明零件 | 增強功能 |
示例一:根據其自身的原始數據格式加載原始數據。
// 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 } }
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()); }
// 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)); }
// 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()); }
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); } }
using (Image image = Image.Load(fileName)) { if (image is VectorImage) { ... } else { ... } }
using (Image image = Image.Load(fileName)) { if (image is IMultipageImage) { var pages = ((IMultipageImage)image).Pages; } }
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); }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn