我想将图像的形状从正方形更改为圆形。之后我打算保存这个位图。但是我遇到了无法将 RoundedBitmapDrawable 转换为位图的问题?或者可能存在另一种将 RoundedBitmapDrawable 实例保存到 SD 卡的方式。
void setImage(){
mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.user);
mImageView.setImageDrawable(createNewBitmap(mBitmap));
mBitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
//after that i am planning save bitmap
}
Drawable createNewBitmap(Bitmap bitmap){
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(),bitmap);
roundedBitmapDrawable.setCornerRadius(bitmapRadius);
roundedBitmapDrawable.setAntiAlias(true);
return roundedBitmapDrawable;
}