此代码:
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:致命异常:主要是 java.lang.ClassCastException:android.graphics.drawable.BitmapDrawable无法强制转换为com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable
答案 0 :(得分:1)
改变这个:
Bitmap photo = ((GlideBitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap();
对此:
Bitmap photo = ((BitmapDrawable)imageView.getDrawable().getCurrent()).getBitmap();