이미지를 메모리에 올리지 않고, 이미지의 사이즈 구하는 방법
( 이는 OutOfMemory 오류를 방지합니다 )
/**
Get Bitmap's Width **/
public static int getBitmapOfWidth(
String fileName ){
try {
BitmapFactory.Options options =
new BitmapFactory.Options();
options.inJustDecodeBounds =
true;
BitmapFactory.decodeFile(fileName, options);
return
options.outWidth;
} catch(Exception e) {
return 0;
}
}
/** Get Bitmap's height **/
public static int getBitmapOfHeight(
String fileName ){
try {
BitmapFactory.Options options =
new BitmapFactory.Options();
options.inJustDecodeBounds =
true;
BitmapFactory.decodeFile(fileName, options);
return options.outHeight;
} catch(Exception e) {
return 0;
}
}
'개발 > Android 개발 주저리' 카테고리의 다른 글
[Android] 3초간 중복터치 막기 (0) | 2014.05.12 |
---|---|
[Android] Android4.4 에서 루팅없이 ADB로 화면 녹화 하기 (2) | 2014.01.11 |
[Android] 국가별 언어 지정 코드(국가 코드) (0) | 2013.01.01 |
[Android]SQLite 기본 명령어 정리 (0) | 2012.05.29 |
[Android] 루팅(rooting)여부 확인하기 (3) | 2012.05.01 |