import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
class Main {
public static Bitmap Drawable2Bitmap(Drawable drawable) {
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
Bitmap bmp = Bitmap
.createBitmap(width, height, Bitmap.Config.ARGB_8888);
drawable.mutate().setBounds(0, 0, width, height);
Canvas c = new Canvas(bmp);
drawable.draw(c);
return bmp;
}
}