Reputation: 1550
I am using AQuery to load images taken by camera and displaying them in my activity in a image view. The problem is that when I try to do the same but instead of taking a picture, just select the image from my gallery, my image view appears to have nothing in it. This is my code:
//Get image uri that was selected in gallery
Uri selectedImage = data.getData();
//Convert uri to string path
strMainPic = selectedImage.toString();
//Create file to add as parameter to AQuery
File Main = new File(strMainPic);
aq.id(R.id.image_one).image(Main, 100);
If I use the selectedImage
and change it to a Bitmap
with BitmapFactory
, it works but the performance suffers. What am I doing wrong?
Upvotes: 1
Views: 500
Reputation: 1550
I just solved it a couple of seconds ago. I used this code:
Uri selectedImage = data.getData();
try {
bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
aq.id(R.id.image_one).image(bmp, AQuery.RATIO_PRESERVE);
I just added this to my onActivityResult()
method.
Upvotes: 2