android 获取资源文件 r.drawable中的图片转换为drawable、bitmap

1

1 Resources resources = mContext.getResources();

2 Drawable drawable = resources.getDrawable(R.drawable.a);

3 imageview.setBackground(drawable);

2

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

3

1 Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);

2 

3 

4 Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 ); 

4

InputStream is = getResources().openRawResource(R.drawable.icon);  

Bitmap mBitmap = BitmapFactory.decodeStream(is);

 

你可能感兴趣的:(drawable)