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);
精彩评论