在android中将图像转换为位图

Abh*_*bhi 6 android bitmap

我想从手机的SD卡中选择一张图片.我使用下面的代码来选择并显示在我的活动中

Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Uri uri = Uri.parse(selectedImagePath);
uploadimage.setImageURI(uri);
Run Code Online (Sandbox Code Playgroud)

它工作正常,但我想将此图像转换为Bitmap,我有图像路径和URI.

在这种情况下如何将图像转换为位图?请帮助我,提前谢谢.

ila*_*o j 20

使用此代码

Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
Run Code Online (Sandbox Code Playgroud)