在我的应用中,我得到了一个图像(位图):
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select"), GET_CODE);
然后,在onActivityResult
中,我从uri获取位图,其中包含:
Uri uri = data.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri); //here I've the error
对于大图像,我收到错误
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 268435468 byte allocation with 16777216 free bytes and 167MB until OOM
如何正确压缩位图?