此代码:
imageView = (ImageView) findViewById(R.id.avatar);
Bitmap photo = ((GlideBitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG,100,bos);
byte[] bArray = bos.toByteArray();
返回此错误:
E/AndroidRuntime:致命异常: main com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable :不能将java.lang.ClassCastException转换为android.graphics.drawable.BitmapDrawable
发布于 2017-08-22 03:13:56
改变这一点:
Bitmap photo = ((GlideBitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap();
对此:
Bitmap photo = ((BitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap();
https://stackoverflow.com/questions/45816040
复制