I'm looking for the fastest way to resize an SKImage. Unfortunately I found a few examples.
I ask this because if I perform these functions in parallel (in my case about 60 threads) the execution time of each single scaling function increases up to twenty times as much.
I tried with the following methods and the performance looks very similar, is there anything better?
Method 1:
SKImage src = (...);
SKImageInfo info = new SKImageInfo(width, height, SKColorType.Bgra8888);
SKImage output = SKImage.Create(info);
src.ScalePixels(output.PeekPixels(), SKFilterQuality.None);
Method 2:
SKImage src = (...);
SKImage output;
float resizeFactorX = (float)width / (float)Src.Width;
float resizeFactorY = (float)height / (float)Src.Height;
using (SKSurface surface = SKSurface.Create((int)(Src.Width *
resizeFactorX), (int)(Src.Height * resizeFactorY),
SKColorType.Bgra8888, SKAlphaType.Opaque))
{
surface.Canvas.SetMatrix(SKMatrix.MakeScale(resizeFactorX, resizeFactorY));
surface.Canvas.DrawImage(Src, 0, 0);
surface.Canvas.Flush();
output = surface.Snapshot();
}
SKSurface.Create(new SKImageInfo { Width = resizedWidth, Height = resizedHeight, ColorType = SKImageInfo.PlatformColorType, AlphaType = SKAlphaType.Premul })
– Sandy