Share via


Is there a way to get Bitmap from ImageView?

Question

Monday, March 24, 2014 4:55 AM

I want to dynamically make a bitmap object which are loaded in an ImageView

ImageView imageView = activity.FindViewById<ImageView> (Resource.Id.imageView1); Bitmap bitmap = imageView.getDrawable() // I am looking for something like this line

How can I extract a drawable object from imageview?

All replies (8)

Monday, March 24, 2014 5:51 AM

Have you tried:

imageView.BuildDrawingCache (true);
Bitmap bitmap = imageView.GetDrawingCache (true);

BitmapDrawable drawable = (BitmapDrawable)imageView.GetDrawable();
Bitmap bitmap = drawable.GetBitmap();

there's your bitmap as the screen saw it.


Monday, March 24, 2014 4:13 PM

thank you!


Wednesday, March 23, 2016 3:53 AM

GetDrawable() method dose not exist on API 15, how can i handle this matter ?


Sunday, March 27, 2016 6:44 AM

have you ever solved this, facing the same issue here


Sunday, March 27, 2016 8:08 AM

this works but . i dont knw how i ended up wth those lines of code .... and am sure i am going in circles can some one make sense of it pls

*ImgView.BuildDrawingCache (true); Bitmap bmap = _ImgView.GetDrawingCache (true); _ImgView.SetImageBitmap(bmap); Bitmap b = Bitmap.CreateBitmap(*ImgView.GetDrawingCache(true));


Thursday, July 7, 2016 1:41 AM

Yayino, thanks a bazillion, that code snippet worked like a charm, I am reposting it with markdown code format:

ImgView.BuildDrawingCache (true); Bitmap bmap = _ImgView.GetDrawingCache (true); ImgView.SetImageBitmap(bmap); Bitmap b = Bitmap.CreateBitmap(_ImgView.GetDrawingCache(true));


Sunday, January 29, 2017 4:27 PM

I know this is a very old post, but this might help some new Xamarin / C# developers.

Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable) imageView.Drawable; Android.Graphics.Bitmap bitmap = bd.Bitmap;


Thursday, August 3, 2017 11:27 PM

@LarrimarTia Thanks You!

Solution this It work for me ^^