Android 接收服务器传来的图片踩过的坑

byte[] data=SocketClientUtil.receiveData(bytes);            //,result
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, outPut);
iv_image.setImageBitmap(bmp);



ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while((len = in.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
Bitmap bmp = BitmapFactory.decodeByteArray(outputStream.toByteArray(), 0, outputStream.toByteArray().length);
//bmp.compress(Bitmap.CompressFormat.JPEG, 100, outPut);
iv_image.setImageBitmap(bmp);
posted @ 2017-06-06 12:40  code666  阅读(1027)  评论(0编辑  收藏  举报