private Bitmap decodeBitmap(File file){
try{
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(file),null,o);
Bitmap currentBitmap = Bitmap.createBitmap(o.outWidth,o.outHeight, Bitmap.Config.ARGB_8888);
final int REQYIRED_SIZE = 800;
int scale = 1;
while (o.outWidth / 2 / scale >= REQYIRED_SIZE && o.outHeight / 2 /scale >= REQYIRED_SIZE){
scale *= 2;
}
//Log.e(TAG, "decodeBitmap: scale---"+scale);
o.inJustDecodeBounds = false;
o.inSampleSize = scale;
o.inMutable = true;
o.inBitmap = currentBitmap;
return BitmapFactory.decodeStream(new FileInputStream(file),null,o);
//return currentBitmap;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
还没有评论,来说两句吧...