[Android] - Bitmap from uri ( PS. ImageSize small or normal )
Android Java 2017. 12. 7. 17:29InputStream is = null;
BufferedInputStream bis = null;
ByteArrayOutputStream out = null;
if( is == null ) {
is = ( InputStream ) conn.getContent();
if( is != null ) {
bis = new BufferedInputStream( is, 8 * 1024 );
out = new ByteArrayOutputStream();
int total = 0;
byte[] buffer = new byte[4096];
while( ( total = bis.read( buffer ) ) != -1 ) {
out.write( buffer, 0, total );
}
out.close();
bis.close();
byte[] data = out.toByteArray();
bitmap = BitmapFactory.decodeByteArray( data, 0, data.length );
}
}
if( is != null ) {
is.close();
}
'Android Java' 카테고리의 다른 글
[Android] - Intent.ACTION_GET_CONTENT FileName 찾기 (0) | 2018.03.27 |
---|---|
[Android] - NavigationView state_checked 배경색상 변경 (0) | 2017.12.14 |
[Android] - WebView loadData 한글 깨짐 ( UTF-8 ) 인코딩 (0) | 2017.11.29 |
[Android] - ListView Scroll on bottom event (0) | 2017.11.29 |
[Android] - Listview 스크롤 최하단 내리기 (0) | 2016.05.15 |