您的位置:首页 > 其它

bitmap 和 drawable 转化

2016-06-29 17:11 246 查看
  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 bitmap=bd.getBitmap();

String fileName = "/data/data/com.test/aa.png; 
Bitmap bm = BitmapFactory.decodeFile(fileName); 
iv.setImageBitmap(bm); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: