开发者

converting image to bitmap in android

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.setI开发者_开发知识库mageURI(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.


use this code

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


Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),uri);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜