name
이라는 path
의 이미지를로드 할 수있는이 작은 기능이 있습니다. 그것은 작동합니다, 문제는 제가 이것을 여러 번 전화해야한다는 것입니다. 예를 들어, 특정 활동의 부하에서 12 번을 가정 해 봅시다. 모두로드하는 데 몇 초가 걸립니다.Android : not optimal 이미지로드
최적인가요? 동일한 결과를 얻는 더 밝은 방법이 있습니까?
public static Bitmap loadImageFrom(File path, String name)
{
try {
File f = new File(path, name);
return BitmapFactory.decodeStream(new FileInputStream(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
나는이 같은
if(!f.exists()) return null;
을 추가하는 시도 :
public static Bitmap loadImageFrom(File path, String name)
{
try {
File f = new File(path, name);
if(!f.exists()) return null;
return BitmapFactory.decodeStream(new FileInputStream(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
나는 그 중복 알고 있지만 내가 할 경우 나에게 오류를주는 원인 나는 시도 캐치 절을 제거 할 수 없습니다. 그러나 아무런 속도도 느껴지지 않았습니다.
의견이 있으십니까?