3

Hi I started a new project and WinForms is new for me. I have a SKBitmap object and I don't know how can I render it.

Kaan EKİN
  • 65
  • 1
  • 8

1 Answers1

7

There are several ways. The first thing to do is to install the SkiaSharp.Views package - a small package that contains platform specific views and utilities for converting SkiaSharp types into the current platform types:

https://www.nuget.org/packages/SkiaSharp.Views/

After installing you should get theses types:

https://developer.xamarin.com/api/namespace/SkiaSharp.Views.Desktop/

Back to the code, you can either add a SKControl and draw the bitmap on the paint event:

control.PaintSurface += (...) => {
    // draw
};

Or, you can convert the bitmap into a Windows bitmap:

var sysBitmap = skBitmap.ToBitmap();

Then, you can just assign it to a PictureBox:

pictureBox.Image = sysBitmap;
Matthew
  • 4,832
  • 2
  • 29
  • 55