C#网络编程 byShow是我收到的图片的二进制流,我想问的是如何把这个流转换成图片并显示在picturebox

来源:百度知道 编辑:UC知道 时间:2024/07/04 17:48:08
能详细一点吗,那些参数怎么用,什么意思
重要的是怎么在picturebox里显示呢

Byte[] byRead = new Byte[2048];
int iRead = stRead.ReceiveFrom(byRead, ref tempRemoteEP);
Byte[] byShow = new Byte[iRead];
Array.Copy(byRead, 0, byShow, 0, iRead);

接下来怎么让这个显示到picturebox呢

public Image ByteArrayToImage(byte[] byteArrayIn, int count)
{
MemoryStream ms = new MemoryStream(byteArrayIn, 0, count);
Image returnImage = Image.FromStream(ms);
return returnImage;
}

// 补充:
Byte[] byRead = new Byte[1024000];
int iRead = stRead.ReceiveFrom(byRead, ref tempRemoteEP);
Image image = ByteArrayToImage(byRead, iRead);// 调用上面的方法
pictureBox1.Image = image;

反射