/**
* 压缩到1080宽或高
*
* @param srcPath
* @return
*/
public static Bitmap getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;
newOpts.inPurgeable = true;
newOpts.inInputShareable = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
int w = newOpts.outWidth;
int h = newOpts.outHeight;
int hh = IMAGE_MAX_SIZE;
int ww = IMAGE_MAX_SIZE;
int be = 1;
if (w > h && w > IMAGE_MAX_SIZE) {
be = (newOpts.outWidth / ww);
} else if (w < h && h > hh) {
be = (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
int rat = readImageExif(srcPath);
if (rat == 0) {
BitmapFactory.Options newOpts2 = new BitmapFactory.Options();
newOpts2.inJustDecodeBounds = false;
newOpts2.inPurgeable = true;
newOpts2.inInputShareable = true;
newOpts2.inSampleSize = be;
bitmap = BitmapFactory.decodeFile(srcPath, newOpts2);
}else{
BitmapFactory.Options newOpts2 = new BitmapFactory.Options();
newOpts2.inJustDecodeBounds = false;
newOpts2.inPurgeable = true;
newOpts2.inInputShareable = true;
newOpts2.inSampleSize = be;
bitmap = BitmapFactory.decodeFile(srcPath, newOpts2);
Matrix m=new Matrix();
m.postRotate(rat);
bitmap = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),m,false);
}
return bitmap;
}