1

I'm getting images from uris, but they aren't showing any of the gallery effects that have been made (ie. grayscale, sepia). I'm hoping to get the edited images. For example:

ContentResolver cr = activity.getContentResolver();
Cursor cur = cr.query(
       MediaStore.Images.Media.EXTERNAL_CONTENT_URI, // data
       new String[] { MediaStore.Images.Media._ID, 
       MediaStore.Images.Media.BUCKET_DISPLAY_NAME }, // Which columns to return
       "", // Which rows to return (all rows)
       null, // Selection arguments (none)
       MediaStore.Images.Media.DATE_ADDED+" DESC" // Ordering
);

ArrayList<String> bucketImageList = new ArrayList<String>();

//get bitmap thumbnails for all albums
if (cur.moveToFirst()) {
       String bucketName;
       String imageID;
       do {
               imageID = cur.getString(cur.getColumnIndex(MediaStore.Images.Media._ID));
               Uri uri = Uri.parse("content://media/external/images/media");
               uri = Uri.withAppendedPath(uri, "" + imageID);
               bucketImageList.add(uri.toString());
       } while (cur.moveToNext());
       cur.close();
       bucketImages = bucketImageList.toArray(new String[bucketImageList.size()]);
} 
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), Uri.parse(bucketImages[2]));

This bitmap will not show any effects made in the Gallery app (Except the Motorola Gallery app).

Randall Stephens
  • 1,037
  • 1
  • 10
  • 16

1 Answers1

0

Your code should look similar to this:

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK)
    {
        Uri imageUri = data.getData();
        Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
    }
}

If you need to load very large images, the following code will load it in in tiles (avoiding large memory allocations):

BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(myStream, false);  
Bitmap region = decoder.decodeRegion(new Rect(10, 10, 50, 50), null);

Also see this answer

Community
  • 1
  • 1
Josef E.
  • 2,179
  • 4
  • 15
  • 30
  • Thanks for your help, but I've managed to load bitmaps from uris. It's just not loading the edits that were made using the Gallery app. It's simply loading the original image. – Randall Stephens Jun 03 '14 at 18:56