Android Bitmap 与 Drawable之间的转换

Bitmap to Drawable:

Drawable drawable = new BitmapDrawable(bitmap);


Drawable to Bitmap:

Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();





但是在互相转换的时候尺寸可能会发生变化,可以采用Drawable d = new BitmapDrawable(getResources(),viewBitmap)来解决。

你可能感兴趣的:(Android Bitmap 与 Drawable之间的转换)