方法一:
Drawable drawable = getResources().getDrawable(R.drawable.a);
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
Bitmap bitmap = bitmapDrawable.getBitmap();
方法二:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a);
Drawable drawable = getResources().getDrawable(R.drawable.a);
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
Bitmap bitmap = bitmapDrawable.getBitmap();
方法二:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a);