【发布时间】:2016-12-03 00:38:51
【问题描述】:
我通过套接字接收 jpg 图像,它作为 ByteBuffer 发送 我正在做的是:
ByteBuffer receivedData ;
// Image bytes
byte[] imageBytes = new byte[0];
// fill in received data buffer with data
receivedData= DecodeData.mReceivingBuffer;
// Convert ByteByffer into bytes
imageBytes = receivedData.array();
//////////////
// Show image
//////////////
final Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes,0,imageBytes.length);
showImage(bitmap1);
但是它无法解码 imageBytes 并且位图为空是怎么回事。
我也得到了 imagebytes: 图像字节:{-1, -40, -1, -32, 0, 16, 74, 70, 73, 70, 0, 1, 1, 1, 0, 96, 0, 0, 0, 0, -1, -37, 0, 40, 28, 30, 35, +10,478 更多}
会有什么问题? 是解码问题吗? 还是从 ByteBuffer 转换为 Byte 数组?
提前感谢您的帮助。
【问题讨论】:
-
it is sent as ByteBuffer。不要这么想。它以字节流的形式发送。 -
DecodeData.mReceivingBuffer。你没有说明你是如何收到数据的。非常不完整的代码。请显示接收字节的十六进制表示法。请发送十六进制字节。
标签: android image bitmap bytearray bytebuffer