`
fonter
  • 浏览: 858439 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Android Bitmap 与 Drawable之间的转换

阅读更多

转换Bitmap to Drawable

 

BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;   
Drawable drawable = (Drawable)bitmapDrawable;   
  
  
Bitmap bitmap = new Bitmap (...);   
Drawable drawable = new BitmapDrawable(bitmap);

 

 

转换Drawable to Bitmap

 

Drawable d = ImagesList.get(0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();

 

分享到:
评论
4 楼 gybin 2012-03-07  
yxl_hg 写道
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;

这个才是正解。    
3 楼 JavaLaDeng 2012-03-01  
要我说,哥们 错误的不要写出来误导人 好吧..
2 楼 yxl_hg 2011-05-24  
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;这一句应该改成BitmapDrawable bd = new BitmapDrawable(bitmap);
1 楼 yxl_hg 2011-05-24  
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;

相关推荐

Global site tag (gtag.js) - Google Analytics