简体   繁体   English

通过UDP接收并显示JPG图像

[英]Receive and display JPG image through UDP

I am a beginner with Andoroid. 我是Andoroid的初学者。 I just create an UDP chanel and receive image package(1000bytes). 我只是创建一个UDP通道并接收图像包(1000字节)。 But I have no idea how to display it. 但是我不知道如何显示它。 What should I do or refer to? 我该怎么办或参考?

If you have access to the packet payload as a byte array you can create and Image instance from it. 如果您可以以字节数组的形式访问数据包有效负载,则可以从中创建Image实例。 Code sample 代码样例

EDIT: 编辑:
If the image is sent in multiple packets you have to order them correctly. 如果图像以多个数据包发送,则必须正确订购它们。 UDP headers has no info for ordering (and there is no guarantee that some won't get lost more info ) so you have to provide your own ordering in the payload or switch to TCP. UDP标头没有用于排序的信息(并且不能保证某些信息不会丢失更多信息 ),因此您必须在有效负载中提供自己的排序或切换到TCP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM