我使用以下方法来防止内存不足异常,但位图始终为空。有人有想法吗?
public Bitmap readBitmap(Android.Net.Uri selectedImage) {
Bitmap bm = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.InSampleSize = 9;
AssetFileDescriptor fileDescriptor = null;
try {
fileDescriptor = this.ContentResolver.OpenAssetFileDescriptor(selectedImage,"r");
} catch (FileNotFoundException e) {
Toast.MakeText(this, e.Message, ToastLength.Long);
}
finally{
try {
bm = BitmapFactory.DecodeFileDescriptor(fileDescriptor.FileDescriptor, null, options);
fileDescriptor.Close();
} catch (IOException) {
}
}
return bm;
}