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

后端 未结 6 1448
感动是毒
感动是毒 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 05:02

    If you like HQ thumbnails, so use [RapidDecoder][1] library. It is simple as follow:

    import rapid.decoder.BitmapDecoder;
    ...
    Bitmap bitmap = BitmapDecoder.from(getResources(), R.drawable.image)
                                 .scale(width, height)
                                 .useBuiltInDecoder(true)
                                 .decode();
    

    Don't forget to use builtin decoder if you want to scale down less than 50% and a HQ result. I tested it in API Level 8 :)

提交回复
热议问题