Just before the project is useful, afraid of forgetting, it is first recorded, and then will use the time directly to copy the use of the good.
1.Bitmap---->drawable:
public static drawable bitmaptodrawable (Bitmap Bitmap) { bitmapdrawable bd = new bitmapdrawable (Bitmap); return BD; }
2.Drawable---->bitmap:
public static Bitmap Drawabletobitmap (drawable drawable) { //Take Drawable's long width int w = drawable.getintrinsicwidth () ; int h = drawable.getintrinsicheight (); Take drawable color format bitmap.config Config = drawable.getopacity ()! = Pixelformat.opaque? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; Bitmap Bitmap = Bitmap.createbitmap (w, H, config); Canvas canvas = new canvas (bitmap); Drawable.setbounds (0, 0, W, h); Drawable.draw (canvas); return bitmap; }
That is over!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Conversion of bitmap and drawable to each other