0
Possible Duplicate:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android誤差在加載圖像以GRIDVIEW加載圖像以網格視圖時發生機器人
下面的錯誤。
java.lang.OutOfMemoryError:位圖大小超過VM預算
請幫助我。有沒有解決這個錯誤的方法。
Possible Duplicate:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android誤差在加載圖像以GRIDVIEW加載圖像以網格視圖時發生機器人
下面的錯誤。
java.lang.OutOfMemoryError:位圖大小超過VM預算
請幫助我。有沒有解決這個錯誤的方法。
試試這個
public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//The new size we want to scale to
final int REQUIRED_WIDTH=WIDTH;
final int REQUIRED_HIGHT=HIGHT;
//Find the correct scale value. It should be the power of 2.
int scale=1;
while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
scale*=2;
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
}
catch (FileNotFoundException e) {}
return null;
}
這將擴大位圖按照寬度和高度傳遞..
什麼是你的位圖size.and SD卡大小> –