안드로이드 개발 질문/답변
(글 수 45,052)
// 파일의 실제 경로 찾아오기 String path = db.getImagePath(id); BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = true; options.inSampleSize = 6; // 이 숫자가 커질수록 사진 크기가 작아져서 속도가 빨라진다 options.inPreferredConfig = Bitmap.Config.RGB_565; // 보통사진 ----------- bitmap = BitmapFactory.decodeFile(path, options); // 속도가 느리다 //-------------------- // 썸네일 ------------ ContentResolver cr = getContentResolver(); int id = Integer.parseInt(uriId); bitmap = MediaStore.Images.Thumbnails.getThumbnail(cr, id, MediaStore.Images.Thumbnails.MICRO_KIND, options); // 썸네일은 크기가 작다. // 썸네일의 크기가 작을 때는 그럭저럭 빠르다 // 썸네일의 크기를 원래 사진의 크기로 키우면 속도가 느려진다 //-------------------- // 회전 bitmap = UIUtil.rotate(this, bitmap, path, uriId); imageview.setImageBitmap(bitmap); // 좌우 스크롤시에는 이런 식으로 이동 Intent i = new Intent(); i.setClass(getApplicationContext(), this.getClass()); i.putExtra(KEY_ID, imageId); startActivity(i); finish(); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
db에 폰에 있는 사진의 uri만 등록해놨다가, 해당 uri를 불러와서, 실제 경로의 사진을 가져오는 예제를 작성하고 있습니다.
근데 문제는 속도가 너무 느립니다...
기본 갤러리 앱이나, 구글코드에 공개된 소스는 속도가 무척 빠른데, 제가 만든건 엄청 느리네요....
QuickPic을 보니까 미리보기 캐시를 사용한다해서 검색해봤는데, 예제 소스 찾기가 힘드네요 ㅠㅠ
좋은 방법 없나요? ㅠㅠ
2011.05.24 17:52:41
imageview.setImageBitmap(bitmap);
아래쪽에 이렇게 하니까 제가 원하는데로 잘 나오네요 ㅎㅎ
대신 맨 처음 나오는 options.inSampleSize는 큰 숫자로 바꿔서 빨리 불러오게 만들었습니다.
options.inSampleSize = 6;
Handler h = new Handler();
Runnable r = new Runnable()
{
@Override
public void run()
{
Bitmap b = BitmapFactory.decodeFile(path, options);
b = UIUtil.rotate(getApplicationContext(), b, path, uriId);
image.setImageBitmap(b);
}
};
h.postDelayed(r, 100);




혹시 썸네일을 BitmapFactory로 직접 생성해서 보여주고 있는건가요?
그러지 마시고 썸네일의 이미지뷰 크기를 고정으로 해두시고
불러온 이미지들을 썸네일이미지뷰에는 사이즈에 맞게 출력하도록 조절하시는게 더 빠르지 않을까요?
썸네일을 일일이 이미지 파일로 만들어 보여주시는 듯 한데.... 아닌가요?