问题描述
我能够在我的 xamarin 应用程序中集成 facebook auth 并设法将 facebook 图像获取到 profileimageview 和其他信息,如姓名和电子邮件。
我已经检查过是否有一个现有的线程,并从那里尝试了解决方案,但是它的方法 不再适用于 API 26
这是方法
ImageView imageView = (ImageView)pic.getChildAt(0);
Bitmap bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
image_ = convertimageToByte(bmp);
基于文档 getDrawable() 已在 api22 折旧
我的目标是从中获取位图并将其作为 base64 字符串保存到 firebase。
解决方法
您可以检查以下代码
ImageView imageView =new ImageView(this);
Bitmap bitmap = ((BitmapDrawable)imageView.Drawable).Bitmap as Bitmap;
MemoryStream baos = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Jpeg,100,baos);
byte[] imageInByte = baos.ToArray();