I really new to Skia, so I'm not really sure how to do even the most basic things...
As far as I know, I should avoid using SKBitmap since it's going to be deprecated in in the future (right?).
So I'm using a "image" as input and a "surface" as output.
I created a paint, a blur filter and then set the paint's filter to the blur filter.
Then I draw the image on the surface using the paint and save it.
But the output image is exactly equal to the input.
So uh... How can I blur a image?
using (var image = SKImage.FromEncodedData(SKData.Create(@"../../../images/testInput.bmp")))
using (var surface = SKSurface.Create(info: new SKImageInfo(image.Width, image.Height)))
using (var canvas = surface.Canvas)
using (var paint = new SKPaint())
using (var filter = SKMaskFilter.CreateBlur(blurStyle: SKBlurStyle.Normal, sigma: 10, flags: SKBlurMaskFilterFlags.HighQuality)) {
paint.IsAntialias = true;
paint.MaskFilter = filter;
paint.BlendMode = SKBlendMode.Difference;
canvas.DrawImage(image, 0, 0, paint);
using (var snapshot = surface.Snapshot())
using (var data = snapshot.Encode(format: SkiaSharp.SKEncodedImageFormat.Png, quality: 100)) {
if (data == null)
throw new InvalidOperationException(nameof(SkiaSharp) + " failed... And didn't explain why.");
using (var fileStream = new FileStream(@"../../../images/testOutput.bmp", FileMode.Create))
data.SaveTo(fileStream);
}
System.Environment.Exit(1);
throw new NotImplementedException();
}