我制作了这段代码来接收图像并将其转换为位图图像,但它不起作用。
这是代码:
public void ReceiveImage()
{
NetworkStream stream = new NetworkStream(socket);
byte[] data = new byte[4];
stream.read(data,0,data.length,0)
int size = BitConverter.ToInt32(data,0);
data = new byte[size];
stream.read(data,0,data.length)
MemoryStream imagestream = new MemoryStream(data);
Bitmap bmp = new Bitmap(imagestream);
picturebox1.Image = bmp;
}
它可以:
Bitmap bmp = new Bitmap(imagestream);
并给我这个错误:
参数无效