我制作了这段代码来接收一张图像并将其转换为位图图像,但它无法正常工作。
以下是代码:
并且给我返回了这个错误:
以下是代码:
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);
并且给我返回了这个错误:
参数无效