UserAvatar = FindViewById<ImageView>(Resource.Id.profilePic);
BitmapDrawable drawable = (BitmapDrawable)UserAvatar.GetDrawableState();
Bitmap bitmap = drawable.Bitmap;
MemoryStream baos = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Png, 100, baos);
byte[] bb = baos.ToArray();
String image = Base64.Encode(bb, Base64Flags.Default).ToString();
I am trying to encode imageview image to base64 string format but i am getting cast exception in
BitmapDrawable drawable = (BitmapDrawable)UserAvatar.GetDrawableState();
into this aboue line please me.I am implemeting this code in c# Xamarin