2012-02-29 41 views

回答

1

你需要趕上低memroy錯誤,並減少下載的圖像的大小如下。

catch(OutOfMemoryError e) 
     { 
      e.printStackTrace(); 
      Log.e("Out of memory error", e.toString()); 
      reduce_size(); 
     } 
..... 

BitmapFactory.Options options=new BitmapFactory.Options(); 
    options.inSampleSize = 8; 
    options.inJustDecodeBounds = true; 

    Bitmap preview_bitmap=BitmapFactory.decodeStream(is,null,options); 

    final int REQUIRED_SIZE=70; 

    int width_tmp=options.outWidth, height_tmp=options.outHeight; 
    int scale=1; 
    while(true){ 
     if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE) 
      break; 
     width_tmp/=2; 
     height_tmp/=2; 
     scale*=2; 
    } 

    //Decode with inSampleSize 
    BitmapFactory.Options o2 = new BitmapFactory.Options(); 
    o2.inSampleSize=scale; 
    Bitmap btm=BitmapFactory.decodeStream(is, null, o2); 
    img_t.setImageBitmap(btm); 
+0

所有的圖像從繪製 – jibysthomas 2012-02-29 08:00:34

+0

不是問題採取使用BitmapDrawable – Maneesh 2012-02-29 08:03:54

+0

但我不能調整他們都是在一個固定大小的圖像。 – jibysthomas 2012-02-29 11:24:57

相關問題