ITeye博客

Android Bitmap 与 Drawable之间的转换

fonter · 2010-05-19 15:07 · android · 移动开发 · Markdown

转换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)

  1. #4 楼 · gybin · 2012-03-07 16:11

    yxl_hg writes:

    BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;

    这个才是正解。 :lol: :lol: :lol: :lol: :lol:

  2. #3 楼 · JavaLaDeng · 2012-03-01 14:27

    要我说,哥们 错误的不要写出来误导人 好吧..

  3. #2 楼 · yxl_hg · 2011-05-24 15:49

    BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;这一句应该改成BitmapDrawable bd = new BitmapDrawable(bitmap);

  4. #1 楼 · yxl_hg · 2011-05-24 15:48

    BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;

评论功能维护中,当前仅展示历史评论。