问题是,即使路径相同,但是当我调用函数时,decodefile函数会返回null。
public static Bitmap lessResolution(String filePath, int width, int height) {
int reqHeight = width;
int reqWidth = height;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
//BitmapFactory.decodeFile(filePath, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth,
reqHeight);
options.inJustDecodeBounds = false;
Bitmap b = BitmapFactory.decodeFile(filePath, options);
Log.d("test1","f:" + filePath);
Log.d("test1","b:" + b);
return b;
}
成功案例:
02-10 09:28:23.554 22444-22444/? D/test1: f:/storage/emulated/0/MyApp/1486690065.jpg
02-10 09:28:23.554 22444-22444/? D/test1: b:android.graphics.Bitmap@8756c
失败案例:
02-10 09:29:22.425 22444-22444/? D/test1: f:/storage/emulated/0/MyApp/1486690065.jpg
02-10 09:29:22.425 22444-22444/? D/test1: b:null
非常感谢你的帮助。