0
클라이언트에서 서버로 웹캠을 스트리밍하려고하는데 바이트 배열에서 서버의 비트 맵으로 변환하는 데 어려움이 있습니다.비트 맵 변환
public void handlerThread()
{
Socket handlerSocket = (Socket)alSockets[alSockets.Count-1];
NetworkStream networkStream = new
NetworkStream(handlerSocket);
int thisRead=0;
int blockSize=1024;
Byte[] dataByte = new Byte[blockSize];
lock(this)
{
// Only one process can access
// the same file at any given time
while(true)
{
thisRead=networkStream.Read(dataByte,0,blockSize);
pictureBox1.Image = byteArrayToImage(dataByte);
if (thisRead==0) break;
}
fileStream.Close();
}
lbConnections.Items.Add("File Written");
handlerSocket = null;
}
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn); //here is my error
Image returnImage = Image.FromStream(ms);
return returnImage;
}
난 다시 이미지와 충돌로 변환 할 때 "매개 변수가 유효하지 않습니다"얻을 위에 표시된 지점에서 :
여기에 코드입니다. 내가 뭘 잘못하고 있는지에 대한 제안은?
내 버퍼 크기가 너무 작았습니다. 먼저 좀 더 테스트해야합니다. – windowskm