<span style="font-size:24px;">//1得到预览图片,获取其大小
Options op=new Options();
op.inJustDecodeBounds=true;//主要是这个参数,如果设置为true就不将图片加载到内存,只是获取该图片的详细信息
Bitmap bm=BitmapFactory.decodeFile(path, op);
//2.获得图片具体的宽高,和要设置的iv控件的宽高,按照比例进行缩放
if(op.outWidth>width||op.outHeight>width){
if(op.outWidth>op.outHeight){
scale=op.outWidth/width;
}
else{
scale=op.outHeight/width;
}
op.inSampleSize=scale;
}
//3.在把预览模式关闭
op.inJustDecodeBounds=false;
//4.最后再重新加载,得到的图片就是缩放好的图片
BitmapFactory.decodeFile(path, op)</span>