Bitmap bitmap = null;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, opts);
opts.inSampleSize = computeSampleSize(opts, -1, 128*128);
opts.inJustDecodeBounds = false;
try {
bitmap = BitmapFactory.decodeFile(filePath, opts);
}catch (Exception e) {
// TODO: handle exception
}
inSampleSize
根據字面意思,輸入的采樣大小。這個值越大,說明壓縮比越高。但是圖片質量越低。