我试图实现Bitmap memeCanvas = BitmapFactory.decodeResource(getResources(), xxx).copy(Bitmap.Config.ARGB_8888, true);
借鉴,我从我的手机上传到我的ImageView
图像。因为我没有像R.drawable.hypotheticalImage
特定绘制路径,我不知道怎么打发因为这是动态的BitmapFactory.decodeResource()
的第二个参数被拉伸的路径相同的信息。
我可以每个请求提供代码。
这是我的解决方案。我只好打电话getContext()
能在一个try-catch块访问getContentResolver()
和包住整个事情。
Bitmap memeCanvas = null;
try {
memeCanvas = BitmapFactory
.decodeStream(getContext()
.getContentResolver()
.openInputStream(imageUri))
.copy(Bitmap.Config.ARGB_8888, true);
} catch (FileNotFoundException e) {
e.printStackTrace();
}