Android Java
[Android] - Bitmap from uri ( PS. ImageSize small or normal )
Vivara
2017. 12. 7. 17:29
반응형
InputStream 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();
}
반응형