Using SkiaSharp, what is the best way to convert SKCanvas-drawn content into a bitmap?

DanVanderboomDanVanderboom USUniversity ✭✭
edited February 2016 in Xamarin.Forms

An app I'm working on needs to dynamically generate bitmap images using vector drawing commands. There are two desired targets: a alpha-channel-friendly bitmap file like .PNG and an ImageSource for binding to Xamarin Forms Image controls, creating and updating app-level DynamicResources, etc.

What is the best way to go about this? Do SKBitmap or SKImage objects have a way to convert to a Bitmap or ImageSource object? Does the SKData object need to produce the raw bytes, and then those are used to hydrate a bitmap object?

Tagged:

Best Answers

  • MigueldeIcazaMigueldeIcaza US Xamurai
    Accepted Answer

    For the next version, I added a convenience AsStream() method on SKData that will allow you to more conveniently get a stream out of an SKData.

Answers

  • MigueldeIcazaMigueldeIcaza USXamarin Team Xamurai
    Accepted Answer

    For the next version, I added a convenience AsStream() method on SKData that will allow you to more conveniently get a stream out of an SKData.

  • hkiddhkidd Member ✭✭

    Is there a way to do this in the opposite direction? I am trying to convert an image to an SKCanvas, annotate on it, and then save that annotated SKCanvas as an image.

    @MigueldeIcaza

  • MigueldeIcazaMigueldeIcaza USXamarin Team Xamurai

    Draw the image into your Canvas.

Sign In or Register to comment.