How to show thumbnail from image path? [closed]

只谈情不闲聊 提交于 2019-12-12 09:26:53

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/13874644/how-to-show-thumbnail-from-image-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!