最近,我用最新版本更新了adobecreativesdk,以支持Android。在编辑器中编辑图像后,我尝试使用onActivityResult中的以下代码获取编辑后的位图:
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上运行良好。但是现在我的位图总是以null的形式返回。我已经设置了图像的URI,就像本文中提到的那样:https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en。我还试着用BitmapFactory.Options调整位图的大小,认为图像可能太大了。但情况似乎并非如此。
发布于 2016-11-08 10:02:42
如果您有Uri图像,最好通过ContentResolver读取它。
Uri uri;
Context context;
try {
Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}ContentResolver为您处理底层存储差异。它同样适用于file://、content://和其他Uri类型。
https://stackoverflow.com/questions/40483752
复制相似问题