/**
* 以最省的方式读取本地图片
* @param context Context
* @param resId 图片id
* @return Bitmap 图像格式
*/
public Bitmap readBitmap(Context context, int resId) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inPurgeable = true;
options.inInputShareable = true;
InputStream is = context.getResources().openRawResource(resId);
Bitmap bitmap = BitmapFactory.decodeStream(is, null, options);
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitmap;
}
本文链接:https://it72.com:4443/441.htm