我从uris获得图像,但它们没有显示任何已经制作的图库效果(即灰度,棕褐色)。我希望得到编辑过的图像。例如:
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]));
此位图不会显示在Gallery应用中产生的任何效果(摩托罗拉图库应用除外)。
答案 0 :(得分:0)
您的代码应该与此类似:
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);
}
}
如果您需要加载非常大的图像,以下代码会将其加载到切片中(避免大量内存分配):
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(myStream, false);
Bitmap region = decoder.decodeRegion(new Rect(10, 10, 50, 50), null);