336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Strange out of memory issue while loading an image to a Bitmap object...TT
안드로이드를 하다보면 비트맵 에러가 많이 난다. ㅜㅠ
요즘은 좀 그래도 덜한데 예전 버젼들은 특히나
아웃오브메모리를 수정하기위해서는 비트맵 옵션을 수정해야한다
비트맵팩토리(bitmapfactory)를 이용하는 방법이다.
비트맵 질을 좀 낮춘다고 해야하나~~
BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 8; Bitmap preview_bitmap=BitmapFactory.decodeStream(is,null,options); private Bitmap decodeFile(File f){ 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_SIZE=70; //Find the correct scale value. It should be the power of 2. int scale=1; while(o.outWidth/scale/2>=REQUIRED_SIZE && o.outHeight/scale/2>=REQUIRED_SIZE) 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; }
'프로그래밍 > 안드로이드' 카테고리의 다른 글
안드로이드에서 이메일 보내는 방법 (0) | 2013.10.03 |
---|---|
안드로이드 상태를 저장하기 (0) | 2013.10.03 |
android.os.NetworkOnMainThreadException (0) | 2013.10.03 |
lazy load of images in ListView (0) | 2013.10.03 |
java에서 post 나 get을 이용해서 웹에있는 파일이나 html 파일을 받아올때 사용하는 함수입니다. (0) | 2013.10.02 |