[英]How send image object through socket…?
我想通过套接字发送图像对象...不想将图像存储在发送者或接收者计算机中...
Use this method: 使用此方法:
ImageIO.write(RenderedImage, String, OutputStream)
Use in your situation: 在您的情况下使用:
Sender 寄件人
BufferedImage image = ....;
ImageIO.write(image, "PNG", socket.getOutputStream());
Receiver 接收器
BufferedImage image = ImageIO.read(socket.getInputStream());
So what have you tried ? 那你试过什么?
This is a tutorial on client/server communication using Java. 这是一个使用Java进行客户端/服务器通信的教程。 This reads from stdin, but in your instance you should probably provide an InputStream on your image object.
这从stdin读取,但在您的实例中,您应该在图像对象上提供InputStream 。
将此序列化用于图像对象以通过套接字发送它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.