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).
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.