Reputation: 9005
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
Reputation: 41
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),uri);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
Upvotes: -1
Reputation: 6037
use this code
Bitmap bmp=BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
Upvotes: 21