读取二值图像

发布于 2024-11-06 03:02:06 字数 411 浏览 0 评论 0原文

我已经启动并运行了套接字通信。

我现在需要以下方面的帮助:

我们将通过套接字将图像发送到设备。

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"

我该如何让它发挥作用?... 现在我只处理纯文本等, 所以这整个二进制编码对我来说是新的。

I've got my socket communication up and running.

I now need help with the following:

We are going to send a image to the device through the socket.

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"

How would I go about getting this to work?..
For now I've just worked with plain text etc,
so this whole binary coding is new to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水微香 2024-11-13 03:02:06

这是您可以在客户端读取数据的示例:

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();

This is an example of you could read data on the client side:

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文