Download and show the Thumbnail

后端 未结 2 999
青春惊慌失措
青春惊慌失措 2021-01-28 22:58

I try to download a picture from URL to SD card/Download. And I try to show its thumbnail in imageview. Now I had below code:

try {
Download(URL);  //download pi         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-28 23:18

    Use Bitmap, Something like,

        try     
        {
            Download(URL);  //download picture to SD card/Download
    
            final int THUMBNAIL_SIZE = 64;
    
            FileInputStream fis = new FileInputStream(Environment.getExternalStorageDirectory() + "/Download/", filename);
            Bitmap imageBitmap = BitmapFactory.decodeStream(fis);
    
            imageBitmap = Bitmap.createScaledBitmap(imageBitmap, THUMBNAIL_SIZE, THUMBNAIL_SIZE, false);
            imageview.setImageBitmap(imageBitmap);
    
        }
        catch(Exception ex) {
    
        }
    

提交回复
热议问题