码迷,mamicode.com
首页 > 移动开发 > 详细

Android Drawable 转化成 Bitmap

时间:2015-02-12 22:54:32      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:android

/*Java代码  将Drawable转化为Bitmap */
  Bitmap drawableToBitmap(Drawable drawable)
  {
   int width = drawable.getIntrinsicWidth();
   int height = drawable.getIntrinsicHeight();
          
   Bitmap bitmap = Bitmap.createBitmap(width, height,drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888: Bitmap.Config.RGB_565);
   Canvas canvas = new Canvas(bitmap);
   //canvas.drawColor(0xff33B5E5);       
   drawable.setBounds(0,0,width,height);
   drawable.draw(canvas);
           
   return bitmap;      
  }

Android Drawable 转化成 Bitmap

标签:android

原文地址:http://blog.csdn.net/zhangphil/article/details/43767535

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!