2012-12-14 69 views

回答

9

你可以從作爲圖像路徑創建圖像縮略圖:

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

+1

不要忘了處理OOM異常,也許你有大圖片以及。 –

+0

非常感謝這對我有用:) –

相關問題