您好我现在调用相机意图whit参数放置图像的位置,如下所示:
imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "tmpPic.jpg"));
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(cameraIntent, 1);
我在活动结果上检索图像:
String filePath = Environment.getExternalStorageDirectory() + "/tmpPic.jpg";
if (yourSelectedImage != null)
yourSelectedImage.recycle();
yourSelectedImage = null;
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath, options);
options.inSampleSize = 1;
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
yourSelectedImage = BitmapFactory.decodeFile(filePath, options);
break;
但在第yourSelectedImage = BitmapFactory.decodeFile(filePath, options);
行中断之前,它会因内存不足而异常下降。我知道样本大小是获取较小图像的方法,但这是一种我可以指定的方式,我想要在640和X大位图和?或者我怎样才能至少跟踪传入的图像太大而我应该使用样本大小?