Peri Hartman
Peri Hartman

Reputation: 19484

skiasharp xamarin forms: antialias on scaled bitmap poor

I'm drawing a bitmap with SkiaSharp in Xamarin Forms. The antialiasing is poor and I would like to know how I can improve it.

The source bitmap has antialiasing, shown in the left of the attached image. The right half shows a part of a screen capture on an Android device.

Source and displayed bitmaps

On the left part, notice that the aliasing is regular - a bit of dark feathering going upward and a bit of light feathering going downward, all uniform. On the right part we still see both feathering but it alternates between double wide pixels and single wide pixels.

When drawing the bitmap

canvas.DrawBitmap(bmpSrc, rectSrcRight, rectDest, paint);

I've tried setting the paint IsAntialiasing() true and false. No significant difference.

In this example, the source image is 61 pixels tall and the Android image is 102.

Am I expecting too much ?

Upvotes: 1

Views: 1294

Answers (1)

Junior Jiang
Junior Jiang

Reputation: 12723

You could have a try with the following code:

SKPaint paint = new SKPaint
{
     IsAntialias = true,
     FilterQuality = SKFilterQuality.High
};
canvas.DrawBitmap(bmpSrc, rectSrcRight, rectDest, paint);

Although IsAntialias will not work for bitmap, I also add it. If you want to draw bitmap continually, it will use more memory.

If you have a better way to make it work and not using more memory, please share here to discuss.

Upvotes: 5

Related Questions