我有以下代码通过套接字连接从Android设备向服务器PC发送图像信息。如何与图像数据一起发送一个Point对象,该对象对应于用户在我已经知道的屏幕上按下的位置?
YuvImage yuv_image = new YuvImage(imageDataArray,
ImageFormat.NV21,
previewWidth,
previewHeight, null);
final ByteArrayOutputStream output_stream = new ByteArrayOutputStream();
Rect rect = new Rect(0, 0, previewWidth, previewHeight);
yuv_image.compressToJpeg(rect, 75, output_stream);
Point p = point;
byte[] array = output_stream.toByteArray();
InetAddress serverAddr = InetAddress.getByName(serverIpAddress);
socket = new Socket(serverAddr, SERVERPORT);
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.write(array);
//Here I would also like to to send the point (p) across, Could even send it as 2 integer values.
无论如何都要发送带有数据的TAG,以便我可以区分服务器端吗?
答案 0 :(得分:0)
我会创建一个可序列化的消息类,它包含一个点和一个图像,并发送它而不是两个对象。