Android BitmapFactory.decodeFile()无法与AdobeImageIntent.EXTRA_输出_URI一起使用
我最近用最新版本更新了adobecreativesdk,以支持Android Nougat。在编辑器中编辑图像后,我尝试使用onActivityResult中的以下代码获取编辑后的位图:Android BitmapFactory.decodeFile()无法与AdobeImageIntent.EXTRA_输出_URI一起使用,android,bitmap,android-7.0-nougat,adobecreativesdk,Android,Bitmap,Android 7.0 Nougat,Adobecreativesdk,我最近用最新版本更新了adobecreativesdk,以支持Android Nougat。在编辑器中编辑图像后,我尝试使用onActivityResult中的以下代码获取编辑后的位图: mImageUri = data.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI); Bitmap bitmap = BitmapFactory.decodeFile(mImageUri.getPath()
mImageUri = data.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI);
Bitmap bitmap = BitmapFactory.decodeFile(mImageUri.getPath());
if(bitmap!=null)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
imagebytes = baos.toByteArray();
PlayAnimation();
}
在更新到最新版本之前,我使用了data.getData()而不是data.getParcelableExtra,它在Android Marshmallow上运行良好。但是现在我的位图总是以null返回。我已经设置了图像的URI,就像这篇文章中提到的那样:
. 我还尝试使用BitmapFactory调整位图的大小。选项认为图像可能太大了。但事实似乎并非如此 如果您有
Uri
图像,最好通过ContentResolver
读取:
Uri uri;
Context context;
try {
Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ContentResolver
为您处理底层存储差异。它同样适用于文件://
、内容://
和其他Uri
类型。mimageri.getPath()
。请告诉我路。它可能是内容展示的一部分。