Aspose.Imaging for .NET v19.9全新發布!3大優化讓操做更簡單!

Aspose.Imaging for .NET點擊下載)是一種高級圖像處理控件,容許開發人員建立,編輯,繪製或轉換圖像。圖像導出和轉換是API核心功能之一,它容許在不安裝Photoshop應用程序或任何其餘圖像編輯器的狀況下保存爲AdobePhotoshop®本機格式。編輯器

近期發佈了Aspose.Imaging for .NET v19.9,優化基本柵格圖像濾波操做,優化RasterCachedImage類中抖動操做,優化Bmp格式的速度或內存等等,下面咱們一塊兒用示例爲你們詳細解讀。優化

主要優化

  • 優化RasterCachedImage類中抖動操做
  • 在基本圖像中支持優化策略調整大小操做
  • 優化基本光柵圖像濾波操做

▲IMAGINGNET-3382支持RasterCachedImage類中抖動操做的優化策略

 //爲目標加載的圖像設置50兆字節的內存限制
using (var image = Image.Load(imageFilePath, new LoadOptions() { BufferSizeHint = 50 })) {
//執行抖動操做
image.Dither(DitheringMethod.FloydSteinbergDithering, 1);
}

▲IMAGINGNET-3456在基本圖像中支持優化策略調整大小操做

//爲目標加載的圖像設置50兆字節的內存限制
using (var image = Image.Load(imageFilePath, new LoadOptions() { BufferSizeHint = 50 })) {
// 執行調整大小操做
image.Resize(300, 200, ResizeType.LanczosResample);
}

▲IMAGINGNET-3457支持基本光柵圖像濾波操做中的優化策略

using Aspose.Imaging.ImageFilters.FilterOptions;

//限制「BigRectangularFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new BigRectangularFilterOptions(); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("BigRectangularFilter.png")
}

//限制「SmallRectangularFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new SmallRectangularFilterOptions(); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("SmallRectangularFilter.png")
}

//限制「MedianFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new MedianFilterOptions(6 /*size*/); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("MedianFilter.png")
}

// 限制「GaussWienerFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new GaussWienerFilterOptions(5 /*radius*/, 1.5 /*smooth*/) { Brightness = 1, Snr = 0.003 }; 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("GaussWienerFilter.png")
}

// 限制「MotionWienerFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new MotionWienerFilterOptions(10 /*length*/, 1 /*smooth*/, 0 /*angle*/) { Brightness = 1, Snr = 0.007 }; 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("MotionWienerFilter.png")
}

// 限制「GaussianBlurFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new GaussianBlurFilterOptions(5 /*radius*/, 4 /*sigma*/); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("GaussianBlurFilter.png")
}

// 限制「SharpenFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new SharpenFilterOptions(); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("SharpenFilter.png")
}

//限制「BilateralSmoothingFilter」過濾的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
FilterOptionsBase filterOptions = new BilateralSmoothingFilterOptions(3 /*size*/); 
rasterImage.Filter(rasterImage.Bounds, filterOptions);
rasterImage.Save("BilateralSmoothingFilter.png")
}

// 限制「BinarizeFixed」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.BinarizeFixed(180 /*threshold*/);
rasterImage.Save("BinarizeFixed.png")
}

//限制「BinarizeOtsu」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.BinarizeOtsu();
rasterImage.Save("BinarizeOtsu.png")
}

//限制「BinarizeBradley」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.BinarizeBradley(-2 /*brightness difference*/);
rasterImage.Save("BinarizeBradley.png")
}

// 限制「灰度」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.Grayscale();
rasterImage.Save("Grayscale.png")
}

// 限制「AdjustBrightness」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.AdjustBrightness(70 /*brightness*/);
rasterImage.Save("AdjustBrightness.png")
}

// 限制「AdjustContrast」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.AdjustContrast(50 /*contrast*/);
rasterImage.Save("AdjustContrast.png")
}

//限制「AdjustGamma」過濾操做的內存使用量(50 Mb)
using (RasterImage rasterImage = (RasterImage)Image.Load("inputImage.png", new LoadOptions { BufferSizeHint = 50 })) {
rasterImage.AdjustGamma(3 /*gamma*/);
rasterImage.Save("AdjustGamma.png")
}
相關文章
相關標籤/搜索