Abhi
Abhi

Reputation: 9005

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.setImageURI(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.

Upvotes: 6

Views: 19853

Answers (2)

pavankumar kavvuri
pavankumar kavvuri

Reputation: 41

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

Upvotes: -1

ilango j
ilango j

Reputation: 6037

use this code

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

Upvotes: 21

Related Questions