【发布时间】:2018-05-14 08:28:10
【问题描述】:
我正在尝试从 Google 登录中保存个人资料图片,我对此有点菜鸟,所以我正在以一种相当迂回的方式进行操作。可能有更好的方法来做到这一点,如果你知道,请告诉我。但我认为在我的迂回方式中有一个未提出的问题。所以 - 我们开始吧。
String profilePicUrl = googleSignInAccount.getPhotoUrl().toString();
ImageView intermediaryIV = (ImageView)
findViewById(R.id.intermediary);
Glide.with(this).load(profilePicUrl).into(intermediaryIV);
ColorDrawable drawable = (ColorDrawable) intermediaryIV.getDrawable();
Bitmap toSaveBitmap = drawable.get; //??
savePicToInternalStorage(toSaveBitmap)
Glide api (https://github.com/bumptech/glide) 将图像从 google 加载到 imageView 中,然后我从 imageview 中抓取可绘制对象。但在这种情况下,我没有得到一个普通的 bitmapDrawable 我得到一个不包含 .toBitmap() 函数的 colorDrawable。这给我带来了一个问题,因为我需要保存位图。
所以问题是我可以将 colorDrawable 转换为位图吗?
另外,如果您有更好的方法来保存来自 google 的图像,您会在 cmets 中将我链接到该图像吗?我们可以将实际发布的答案留给主要问题。
【问题讨论】:
标签: android bitmap google-signin colordrawable