public static Bitmap getBitmap(ContentResolver cr, String fileName) {
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
// select condition.
String whereClause = MediaStore.Images.Media.DATA + " = '" + fileName
+ "'";
Cursor cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[] { MediaStore.Images.Media._ID }, whereClause,
null, null);
if (cursor == null || cursor.getCount() == 0) {
if (cursor != null)
cursor.close();
return null;
}
cursor.moveToFirst();
// p_w_picpath id in p_w_picpath table.
String videoId = cursor.getString(cursor
.getColumnIndex(MediaStore.Images.Media._ID));
cursor.close();
if (videoId == null) {
return null;
}
long videoIdLong = Long.parseLong(videoId);
// via p_w_picpathid get the bimap type thumbnail in thumbnail table.
bitmap = MediaStore.Images.Thumbnails.getThumbnail(cr, videoIdLong,
Images.Thumbnails.MINI_KIND, options);
return bitmap;
}
转载于:https://blog.51cto.com/426445/1217025
最后
以上就是简单板凳最近收集整理的关于利用系统媒体库获取缩略图的全部内容,更多相关利用系统媒体库获取缩略图内容请搜索靠谱客的其他文章。
发表评论 取消回复