Xamarin Form SkiaSharp SKMatrix transformation

MisterXamarin 1 Reputation point
2021-03-29T07:54:12.437+00:00

Hi,
I try to solve my problem with SkMatrix in SkiaSharp :

I want to transform my Bitmap1 (corners A, B, C, D) and resize it to my full container (corners 1, 2, 3, 4) with Matrix transform.

(Of course the Bitmap will be a bit distorted ...)

Help of expert would be appreciated ;-)

Thanks

82361-sample.jpg

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,936 Reputation points
    2021-03-29T13:43:51.31+00:00

    I want to transform my Bitmap1 (corners A, B, C, D) and resize it to my full container (corners 1, 2, 3, 4) with Matrix transform.

    Hi, MisterXamarin-2605. To resize an SKBitmap to fill an SKCanvasView, try using the Resize method.

    var resizedBitmap = bitmap.Resize(info, SKBitmapResizeMethod.Box);
    canvas.DrawBitmap(resizedBitmap, info.Width / 2 - resizedBitmap.Width / 2, info.Height / 2 - resizedBitmap.Height / 2);
    

    Refer to: https://forums.xamarin.com/discussion/comment/342107/#Comment_342107

    0 comments No comments