Replies: 5 comments 4 replies
-
I'm doing exactly the same, with way larger images, and I don't see any issue. I only noticed that quality degrades when downscaling images more than 50%, not when saving a large canvas. Can you share code? |
Beta Was this translation helpful? Give feedback.
-
I saw that the image is saved according to the device screen size, so if the image size is more than 50% of the screen size, the quality decreases? (my device size: 1146x750), and how can I fix it? |
Beta Was this translation helpful? Give feedback.
-
If you want a large canvas, then create one. For example: using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using SkiaSharp;
public class Program
{
public static void Main()
{
Console.WriteLine("Downloading photo...");
using var wc = new WebClient();
using var stream = wc.OpenRead("https://upload.wikimedia.org/wikipedia/commons/4/47/Colletes_inaequalis%2C_female%2C_back1_2012-08-10-15.38.49_ZS_PMax_%287918574678%29.jpg");
using var photo = SKBitmap.Decode(stream);
Console.WriteLine("Drawing photo at 50%..");
using var target = new SKBitmap(photo.Width / 2, photo.Height / 2);
using var canvas = new SKCanvas(target);
using var paint = new SKPaint
{
FilterQuality = SKFilterQuality.Low
};
canvas.DrawBitmap(photo, new SKRect(0, 0, target.Width, target.Height), paint);
Console.WriteLine("Saving photo...");
using var data = target.Encode(SKEncodedImageFormat.Jpeg, 92);
using var output = File.Create(Path.Combine(Path.GetTempPath(), "output.jpg"));
data.SaveTo(output);
output.Close();
Console.WriteLine("Opening photo...");
Process.Start(new ProcessStartInfo(output.Name) { UseShellExecute = true });
}
} |
Beta Was this translation helpful? Give feedback.
-
But yet, IMHO Skia makes photos blurry when downscaling >50%, but that is subjective. To work around this, I created a high quality downscaler, that is slower than Skia, but higher quality. |
Beta Was this translation helpful? Give feedback.
-
Is there a solution for Xamarin.Forms? I'm using Xamarin.Forms |
Beta Was this translation helpful? Give feedback.
-
I'm trying to load big size image (39.1 MB, dimensions: 5494x5839) into a SKCanvas, enable drawing on it, and save the canvas as new .png image.
But the new image loses the quality, it's saved as 1.71 MB size with the device dimensions.
Why the canvas is saved as lower resolution than the original image? Does SKCanvas not supported big size images?
Beta Was this translation helpful? Give feedback.
All reactions