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 은 비트맵 사이즈를 리사이징 하는 부분
댓글 없음:
댓글 쓰기