我的套接字通信已启动并正在运行。
我现在需要以下方面的帮助:
我们将通过套接字将图像发送到设备。
transmit.framebuffer.rgb_byte will transmit in binary format the following information:
[4 bytes] => image width
[4 bytes] => image height
[< image width> * <image height> * 3 bytes] => RGB in unsigned char format [0, 255]
[3 bytes] "OK\n"
我将如何开始这项工作?
现在,我只使用纯文本等,
所以整个二进制编码对我来说是新的。
最佳答案
这是一个示例,您可以在客户端读取数据:
out = new ByteArrayOutputStream();
in = new BufferedInputStream(socket.getInputStream(), BUFFER_SIZE);
byte[] dataBuffer = new byte[1024 * 16];
int size = 0;
while ((size = in.read(dataBuffer)) != -1) {
out.write(dataBuffer, 0, size);
}
out.flush();
byte[] bytesReceived = out.toByteArray();
关于java - 读取二进制图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5955012/