Android: Get thumbnail of image on SD card, given Uri of original image

后端 未结 6 1449
感动是毒
感动是毒 2020-11-29 04:24

So i\'ve got a Uri of an image the user chooses out of images off his SD card. And i\'d like to display a thumbnail of that image, because obviously, the image could be huge

6条回答
  •  没有蜡笔的小新
    2020-11-29 04:58

    You can simply create thumbnail video and image using ThumnailUtil class of java

    Bitmap resized = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(file.getPath()), width, height);
    
    
     public static Bitmap createVideoThumbnail (String filePath, int kind)
    

    Added in API level 8 Create a video thumbnail for a video. May return null if the video is corrupt or the format is not supported.

    Parameters filePath the path of video file kind could be MINI_KIND or MICRO_KIND

    For more Source code of Thumbnail Util class

    Developer.android.com

提交回复
热议问题