当前位置: 代码迷 >> Android >> Android Drawable 转化成 Bit地图
  详细解决方案

Android Drawable 转化成 Bit地图

热度:493   发布时间:2016-04-28 02:19:12.0
Android Drawable 转化成 Bitmap
/*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;        }

  相关解决方案