从资源文件中获取Bitmap:
【1】先获取Resource,然后可以通过资源ID获取Drawable
Drawable d = r.getDrawable(R.drawable.xxx));
【2】通过资源ID获取资源文件的数据流,再获取Bitmap
InputStream is = r.openRawResource(R.drawable.xxx);
Bitmap bitmap ;
①使用BitmapDrawable:
BitmapDrawable bd = new BitmapDrawable(is)); bitmap = bd.getBitmap();
②使用BitmapFactory
bitmap = BitmapFactory.decodeStream(is));