How To Convert Uri To Bitmap?
I Am Making An Image Filter App And Before Applying Filter I Will Crop The Image As Square, I Can Crop The Image Using Soundcloud Library Like This:- private void beginCrop(String
Solution 1:
To convert URI to the bitmap you can do as follows.
try {
if( Uri.parse(paths)!=null ){
Bitmapbitmap= MediaStore.Images.Media.getBitmap(c.getContentResolver() , Uri.parse(paths));
}
}
catch (Exception e) {
//handle exception
}
When you are getting file form file picker or camera intent then you can do this.
protectedvoidonActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
UriimageUri= data.getData();
Bitmapbitmap= MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
}
}
Post a Comment for "How To Convert Uri To Bitmap?"