我正在创建一款展示所有图片的“画廊”应用程序,以网格形式显示。
我曾试图查询真实的照片数据并检索其方向,但过程太慢(需要几秒钟),而且显示的图片太大。
问题在于:某些图片显示方向不正确。
以下是检索缩略图的代码:
final String[] projection = { MediaStore.Images.Thumbnails.DATA, MediaStore.Images.Thumbnails.IMAGE_ID };
//query the thumbnails provider
Cursor thumbnailsCursor = context.getContentResolver().query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, null,
null, null);
if (thumbnailsCursor.moveToFirst()) {
do {
//get the thumbnail path
fullPath = thumbnailsCursor.getString(fullPathColumnIndex);
thumbnailUri = Uri.parse(fullPath);
//add the uri to the list
thumbnailsList.add(thumbnailUri);
} while (thumbnailsCursor.moveToNext());
thumbnailsCursor.close();
在BaseAdapter
的getView()
方法中,我使用了Picasso
图像加载库来显示缩略图,但有时方向不正确。
Picasso.with(context).load(new File(photoItem.thumbnail.getPath())).noFade().into(holder.photoImageView);
我曾试图查询真实的照片数据并检索其方向,但过程太慢(需要几秒钟),而且显示的图片太大。