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

android将drawable下的图片转换成bitmap

时间:2017-04-11 12:06:31      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:icon   code   inpu   open   context   rgb   etc   puts   xxx   

将drawable下的图片转换成bitmap

1、 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.xxx);

2、Resources r = this.getContext().getResources();
      Inputstream is = r.openRawResource(R.drawable.xxx);
      BitmapDrawable  bmpDraw = new BitmapDrawable(is);
      Bitmap bmp = bmpDraw.getBitmap();

3、Resources r = this.getContext().getResources();

      Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
      Bitmap bmp = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );

将drawable下的图片转换成Drawable

Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);

android将drawable下的图片转换成bitmap

标签:icon   code   inpu   open   context   rgb   etc   puts   xxx   

原文地址:http://www.cnblogs.com/JLZT1223/p/6692243.html

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