如何从图像路径显示缩略图?

时间:2012-12-14 07:50:19

标签: android imageview thumbnails show

如何在ImageView中显示固定图像路径的缩略图?

1 个答案:

答案 0 :(得分:8)

您可以从图像路径创建图像缩略图:

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;
}

在文件路径上调用此方法单击以在ImageView中显示图像缩略图

相关问题