Android Bitmap 与 Drawable之间的转换

来源:互联网 发布:c 数组删除指定元素 编辑:程序博客网 时间:2024/04/30 19:46

转换Bitmap to Drawable

 

Java代码  收藏代码
  1. BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;     
  2. Drawable drawable = (Drawable)bitmapDrawable;     
  3.     
  4.     
  5. Bitmap bitmap = new Bitmap (...);     
  6. Drawable drawable = new BitmapDrawable(bitmap);  

 

 

转换Drawable to Bitmap

 

Java代码  收藏代码
  1. Drawable d = ImagesList.get(0);  
  2. Bitmap bitmap = ((BitmapDrawable)d).getBitmap();  
原创粉丝点击