在Android中将图像转换为位图 [英] converting image to bitmap in android

查看:238
本文介绍了在Android中将图像转换为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从手机的SD卡中选择图片.我正在使用以下代码进行选择并显示在我的活动中

i want to choose a picture from SD card of the mobile. i am using below code to choose and to display in my activity

Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Uri uri = Uri.parse(selectedImagePath);
uploadimage.setImageURI(uri);

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

It is working fine, but I want to convert this image into Bitmap, I have image path and URI.

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

How to convert image to Bitmap in this case? Please help me, thanks in advance.

推荐答案

使用此代码

Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));

这篇关于在Android中将图像转换为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆