android将drawable下的图片转换成bitmap

壮心未与年俱老,死去犹能作鬼雄。这篇文章主要讲述android将drawable下的图片转换成bitmap相关的知识,希望能为你提供帮助。
将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
【android将drawable下的图片转换成bitmap】Resources resources = mContext.getResources();
Drawable drawable = resources.getDrawable(R.drawable.a);
imageview.setBackground(drawable);







    推荐阅读