Bitmap Turn drawable
Bitmap bm=xxx; bitmapdrawable bd=new bitmapdrawable (BM);
Because Btimapdrawable is a subclass of drawable, it is finally possible to use the BD object directly.
drawable turn Bitmap
drawable d=== Bd.getbitmap ();
Finally, BM is the bitmap object we need.
get bitmap from your resources
Public Static int resId) { = act.getresources (); return Bitmapfactory.decoderesource (res, resId);}
byte[]→bitmap
public static Bitmap Convertbytes2bimap (byte [] b) { if (b.length = = 0 return null ; } return Bitmapfactory.decodebytearray (b, 0
bitmap→byte[]
public static byte [] convertbitmap2bytes (Bitmap BM) {Bytearrayoutputstream BAOs = Span style= "color: #0000ff;" >new Bytearrayoutputstream (); Bm.compress (Bitmap.CompressFormat.PNG, 100 return Baos.tobytearray ();}
drawable→bitmap
public static Bitmap Convertdrawable2bitmapbycanvas (drawable drawable) {Bitmap Bitmap = Bitmap.createbitmap (drawable.getin Trinsicwidth (), Drawable.getintrinsicheight (), drawable.getopacity ()! = Pixelformat.opaque? Bitmap.Config.ARGB_8888:Bitmap.Config.RGB_565); Canvas Canvas = new canvas (bitmap); // Canvas.setbitmap (bitmap); Drawable.setbounds (0, 0 return bitmap;}
I'm the dividing line of the king of the land Tiger.
Android--drawable && Bitmap