How to convert rapidly ; An Android.Graphics.Bitmap
To a SkiaSharp.SKBitmap
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.
ToSKBitmap no longer exist in Xamarin, could you help ?
Below is a sample code how to convert Andriod bitmap Barcode to stream
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);
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies