[Android] 안드로이드 bitmap 불러오지 않고 사이즈 알아보기!

/** 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;
    }
}

options.inJustDecodeBounds = true; // 이 옵션을 통해서 메모리에 올리지 않고 사이즈를 알 수 있습니다.

댓글