图像存储在SD卡的路径是已知的Android开缩略图 [英] android get thumbnail of image stored on sdcard whose path is known
本文介绍了图像存储在SD卡的路径是已知的Android开缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
都说我是个形象店,在路径到/ mnt /图片/ abc.jpg
。我如何生成的缩略图位图这一形象系统。我知道如何从它的URI图像的缩略图,而不是从它的文件路径
Say I have an image stores at path "/mnt/images/abc.jpg"
. How do I get the system generated thumbnail bitmap for this image. I know how to get the thumbnail of an image from its Uri, but not from its file-path
推荐答案
您可以用这个试试:
public static Bitmap getThumbnail(ContentResolver cr, String path) throws Exception {
Cursor ca = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] { MediaStore.MediaColumns._ID }, MediaStore.MediaColumns.DATA + "=?", new String[] {path}, null);
if (ca != null && ca.moveToFirst()) {
int id = ca.getInt(ca.getColumnIndex(MediaStore.MediaColumns._ID));
ca.close();
return MediaStore.Images.Thumbnails.getThumbnail(cr, id, MediaStore.Images.Thumbnails.MICRO_KIND, null );
}
ca.close();
return null;
}
这篇关于图像存储在SD卡的路径是已知的Android开缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文