android 中怎样将 R.drawable里面的图片资源转成换Bitmap型

2024-12-05 02:35:34
推荐回答(2个)
回答1:

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

Bitmap mBitmap = BitmapFactory.decodeStream(is);

回答2:

Bitmap bmp=BitmapFactory.decodeResource(r, R.drawable.icon);
Bitmap newb = Bitmap.createBitmap( 300, 300, Config.ARGB_8888 );
Canvas canvasTemp = new Canvas( newb );
canvasTemp.drawBitmap(bmp, 50, 50, p);