如何使用TCP连接在两个Windows应用程序之间传输图像。请帮助我。提前谢谢。 [英] How to transfer image between two windows application using TCP connection.Pls help me.Thanks in advance.

查看:65
本文介绍了如何使用TCP连接在两个Windows应用程序之间传输图像。请帮助我。提前谢谢。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用TCP连接在两个Windows应用程序之间传输图像。请帮我。谢谢。

解决方案

1)创建基于套接字的客户端服务器架构如下例所示: http://www.dodgycoder.net/2012/ 08 / tcpip-sockets-in-net-4.html [ ^ ]

2)如您所见,有一个要写入的流和一个要读取的流。您可以将任何图像序列化为流:

图像im = Image.FromFile( @  C:\image.jpg); 
MemoryStream ms = new MemoryStream();
im.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);



同样,你可以创建一个图像 FromStream [ ^ ]在另一端


How to transfer image between two windows application using TCP connection.Pls help me.Thanks in advance.

解决方案

1) Create a socket based clien-server architecture like in the following sample: http://www.dodgycoder.net/2012/08/tcpip-sockets-in-net-4.html[^]
2) As you see, there is a stream to write and one to read. You can serialize any image to a stream:

Image im = Image.FromFile(@"c:\image.jpg");
MemoryStream ms = new MemoryStream();
im.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 


Likewise you can create an image FromStream[^] at the other end.


这篇关于如何使用TCP连接在两个Windows应用程序之间传输图像。请帮助我。提前谢谢。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆