一般用摄像头拍摄的图片都会大于1M,
在anroid中载入这种大图片的时候很容易内存不足,
这时候我们可以对大图进行缩放,普通的图片则正常显示
- File file = new File(path);
- byte[] all=...;//path文件的byte
- if(file.length()>1024*1024){
- BitmapFactory.Options options=new BitmapFactory.Options();
- options.inSampleSize=10;//图片缩放比例
- bmp = BitmapFactory.decodeByteArray(all, 0, all.length,options);
- }else{
- bmp = BitmapFactory.decodeByteArray(all, 0, all.length);
- }
- mImageView.setImageBitmap(bmp);