Forum Libraries, Components, and Plugins


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Android bitmap conversion

How to convert rapidly ; An Android.Graphics.Bitmap
To a SkiaSharp.SKBitmap


  • mattleibowmattleibow ZAXamarin Team Xamurai

    This is easy to do, you just need to have the SkiaSharp.Views NuGet package installed. Then, there are extension methods:

    skiaBitmap = androidBitmap.ToSKBitmap();
    androidBitmap = skiaBitmap.ToBitmap();

    There are also a few others, like: ToSKImage and ToSKPixmap.

    NOTE: these all make copies of the pixel data. To avoid memory issue, you can dispose of the original as soon as the method returns.

  • Chris94Chris94 Member ✭✭

    ToSKBitmap no longer exist in Xamarin, could you help ?

  • HanHan Member

    Below is a sample code how to convert Andriod bitmap Barcode to stream

    using ZXing.Mobile;
    using SkiaSharp.Views;
    using SkiaSharp.Views.Android;

    private SKBitmap convertBarcodeToSKBitmap()
    var barcodeWriter = new ZXing.Mobile.BarcodeWriter
    Format = ZXing.BarcodeFormat.CODE_39,
    Options = new ZXing.Common.EncodingOptions
    Width = 50,
    Height = 50,
    Margin = 5
    var barcode = barcodeWriter.Write("1234567");
    SKBitmap _bitmap = SkiaSharp.Views.Android.AndroidExtensions.ToSKBitmap(barcode);

            return _bitmap;
Sign In or Register to comment.