1 Bitmap 转成 Drawable
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=new BitmapDrawable(bm);
因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
2 R.drawable.ic_launcher转Bitmap
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launch);
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)
3 Drawable 转成 Bitmap
BitmapDrawable bd=(BitmapDrawable)drawable;
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=new BitmapDrawable(bm);
因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
2 R.drawable.ic_launcher转Bitmap
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launch);
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)
3 Drawable 转成 Bitmap
BitmapDrawable bd=(BitmapDrawable)drawable;
Bitmap bitmap=bd.getBitmap();
String fileName = "/data/data/com.test/aa.png;
Bitmap bm = BitmapFactory.decodeFile(fileName);
iv.setImageBitmap(bm);