如何保存RoundedBitmapDrawable

时间:2017-10-24 14:30:28

标签: android drawable android-bitmap bitmapfactory roundedbitmapdrawable

我想将图像的形状从正方形更改为圆形。之后我计划保存这个位图。但我遇到问题我不能将RoundedBitmapDrawable强制转换为Bitmap?或者可能存在另一种将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;
}

0 个答案:

没有答案