OOM
需要缩略图 (可以设置) android:scaleType="fitXY"
public static Bitmap getMiniMap(String path, int size) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options); // 此时返回bm为空
options.inJustDecodeBounds = false;
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be;
if (options.outHeight > options.outWidth) {
be = (int) (options.outHeight / (float) size);
} else {
be = (int) (options.outWidth / (float) size);
}
if (be <= 0)
be = 1;
options.inSampleSize = be;
options.inPreferredConfig = Bitmap.Config.RGB_565;
options.inPurgeable = true;
options.inInputShareable = true;
// 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
return BitmapFactory.decodeFile(path, options);
}