How to show thumbnail from image path? [closed]

2020-08-04 03:47发布

How can I show a thumbnail from a fixed image path in an ImageView?

1条回答
闹够了就滚
2楼-- · 2020-08-04 04:21

you can create Image thumbnail from the image path as:

public Bitmap getbitpam(String path){
    Bitmap imgthumBitmap=null;
     try    
     {

         final int THUMBNAIL_SIZE = 64;

         FileInputStream fis = new FileInputStream(path);
          imgthumBitmap = BitmapFactory.decodeStream(fis);

         imgthumBitmap = Bitmap.createScaledBitmap(imgthumBitmap,
                THUMBNAIL_SIZE, THUMBNAIL_SIZE, false);

        ByteArrayOutputStream bytearroutstream = new ByteArrayOutputStream(); 
        imgthumBitmap.compress(Bitmap.CompressFormat.JPEG, 100,bytearroutstream);


     }
     catch(Exception ex) {

     }
     return imgthumBitmap;
}

call this method on filepath click to show Image thumbnail in ImageView

查看更多
登录 后发表回答