티스토리 뷰
public Bitmap assetsRead(String file) {
InputStream is;
Bitmap bitmap = null;
try {
is = mContext.getAssets().open(file);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
bitmap = BitmapFactory.decodeByteArray( buffer, 0, buffer.length ) ;
bitmap = Bitmap.createScaledBitmap(bitmap, 300, 340, true);
} catch (IOException e) {
e.printStackTrace();
}
return bitmap ;
}
매개변수는 파일 경로를 넣어주면 된다. 소스에 300, 340 은 비트맵 사이즈를 리사이징 하는 부분
'개발 > 개발 자료' 카테고리의 다른 글
| (Android) SurfaceView Canvas 를 Bitmap으로 저장하기(가져오기) (5) | 2014.03.26 |
|---|---|
| (Android) RelativeLayout 코드로 구현하기 (2) | 2014.03.26 |
| (Android) String.format 이용하기 (0) | 2014.03.24 |
| (Android) 안드로이드에서 플래시 실행하기 (3) | 2014.03.21 |
| (Android) 프로가드, 난독화 적용하기 (0) | 2014.03.18 |
댓글
