Drawable和Bitmap转换

一、Bitmap转Drawable

Bitmap mBitMap=getYourBitMap(); //getYourBitMap()是你获取BitMap的方法

BitmapDrawable mBitDrawable=new BitmapDrawable(mBitMap);

//BtimapDrawable是Drawable的子类,直接把mBitDrawable对象当作Drawable使用即可。

 

二、 Drawable转Bitmap

Drawable mDrawable=getYourDrawable (); //getYourDrawable()是你获取Drawable 的方法

BitmapDrawable mBitDrawable= (BitmapDrawable) mDrawable;

Bitmap mBitMap= mBitDrawable.getBitmap(); //最后通过mBitDrawable的自带的方法获取需要的Bitmap对象。

posted @ 2014-11-23 00:48  RexWei  阅读(261)  评论(0编辑  收藏  举报