在C#Visual Studio中将图片框图像从服务器发送到客户端 [英] Sending a picturebox image from server to client in c# visual studio

查看:89
本文介绍了在C#Visual Studio中将图片框图像从服务器发送到客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在客户端/服务器通信中,(服务器端)我将图像加载到图片框中,并且我想将此图像发送到客户端并显示在其图片框中.我该怎么做?
我在Google中搜索过,找不到任何地方,
请帮助我


在此先感谢

Amith



In a client/server communication,(server side) i load an image in picturebox and i want to send this image to the client and display in its picturebox. How do i do it?
I searched in Google , could not find any where,
please help me


Thanks in advance

Amith

推荐答案

1)将PictureBox的Image属性转换为字节流.
2)将字节流发送到客户端.
3)将字节转换为图像.
4)将图像加载到PictureBox.Image属性中.

将图像转换为byte []数组:

1) Convert the Image property of the PictureBox to a stream of bytes.
2) Send the stream of bytes to the client.
3) Convert the bytes to an Image.
4) Load the Image into a PictureBox.Image property.

Convert Image to byte[] array:

MemoryStream ms = new MemoryStream();
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);
return ms.ToArray();



将byte []数组转换为Image:



Convert byte[] array to Image:

MemoryStream ms = new MemoryStream(bytes);
Image returnImage = Image.FromStream(ms);
return returnImage;


这篇关于在C#Visual Studio中将图片框图像从服务器发送到客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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