예전에 개발하면서 문제 됬던 내용 정리 하는 차원에서 작성한다.
1. 재현현상
BitmapDrawable 으로 이미지 파일을 외장/내장 Disk 에서 불러올경우 이미지 사이즈가 작아지거나 커지는 현상이 발생 되었다.
2. 수정방법
아래와 같이 구현 하여 해결 해였다.
/** * 이미지 파일을 drawable에 넣는다 * @param path 이미지 파일 경로 * @return */ public static BitmapDrawable getBitmapDrawableFromFile(String path) { BitmapDrawable drawable = null; try { Bitmap bitmap = null; FileInputStream Stream; Stream = new FileInputStream(path); bitmap = BitmapFactory.decodeStream(Stream); Stream.close(); Stream = null; drawable = new BitmapDrawable(bitmap); //이미지 Density를 세팅하지 않으면 이미지 크기가 작게 나옴 보통 단말 Density로 세팅된다/ drawable.setTargetDensity(drawable.getBitmap().getDensity()); } catch (Exception e) { e.printStackTrace(); } return drawable; }
'Android > Tip' 카테고리의 다른 글
BitmapFactory.Options 사용시 주의 사항 (0) | 2014.03.17 |
---|---|
OpenGL, Surfaceview 에서 Navigation Drawer, Sliding Menu 구현시 주의사항 (0) | 2014.03.10 |
앱이 Background 상태인경우 간혈적으로 앱이 강제종료 되는거 막기 (0) | 2014.03.10 |
구글 PlayStore APK 업로드시 주의사항 (0) | 2014.03.10 |
진저브레드나 진저브레드 이하버전 에서 ListView itemView Type 2가지 이상인 경우 처리 방법 (0) | 2014.03.10 |