Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

What is the best way to convert an Android Bitmap to an ImageSource?

$
0
0

I have tried:

            Parcel p = Parcel.Obtain();
            bmp.WriteToParcel( p, ParcelableWriteFlags.None );

            var imgsrc = ImageSource.FromStream( () => new MemoryStream( p.CreateByteArray() ) );

Where "bmp" is of class Android.Graphics.Bitmap. I have tried:

            var imgsrc = ImageSource.FromStream( () => 
            {
                MemoryStream ms = new MemoryStream();
                bmp.Compress( Bitmap.CompressFormat.Jpeg, 100, ms );
                return ms;
            } );

And a few others I'm forgetting at the moment. Needless to say, I get a blank image in the form. How do I accomplish this?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>