Closed
Description
Description
As @AndersMad discovered in #319 SKImage resizes very blurry, whereas resizing a SKBitmap works great.
Code
SKBitmap srcBitmap = ...
// Use attached "boat.jpg". A large image like this provides a more dramatic resize comparison
// (e.g. 5400x3615px). The more dramatic the resize, the more dramatic the resize quality between
// SKImage and SKBitmap.
int resizedWidth = 160, resizedHeight = 107;
// SKImage resizes blurry
using (var surface = SKSurface.Create(resizedWidth, resizedHeight, SKImageInfo.PlatformColorType,
SKAlphaType.Premul))
using (var paint = new SKPaint())
{
// high quality with antialiasing
paint.IsAntialias = true;
paint.FilterQuality = SKFilterQuality.High;
// draw the bitmap to fill the surface
surface.Canvas.DrawBitmap(srcBitmap, new SKRectI(0, 0, resizedWidth, resizedHeight),
paint);
surface.Canvas.Flush();
// save
using (var newImg = surface.Snapshot())
using (SKData data = newImg.Encode(SKEncodedImageFormat.Jpeg, 100))
using (Stream imgStream = data.AsStream())
{
// save the stream and look at the image. e.g. "blurry.jpg"
}
}
// SKBitmap resizes crisp.
SKImageInfo resizeInfo = new SKImageInfo(resizedWidth, resizedHeight);
using (SKBitmap resizedSKBitmap = srcBitmap.Resize(resizeInfo, SKBitmapResizeMethod.Lanczos3))
using (SKImage newImg = SKImage.FromPixels(resizedSKBitmap.PeekPixels()))
using (SKData data = newImg.Encode(SKEncodedImageFormat.Jpeg, jpegQuality))
using (Stream imgStream = data.AsStream())
{
// save the stream and look at the image. e.g. "crisp.jpg"
}
Expected Behavior
SKImage should be able to resize with the same good quality as SKBitmap
Actual Behavior
SKImage resizes very blurry.
Basic Information
- Version with issue: 1.60.0
- Last known good version:
- IDE: Visual Studio
- Platform Target Frameworks: .NET Core 2.0 (AWS Lambda)
Attachments
Metadata
Metadata
Assignees
Labels
No labels