B
bull.enteract
Ok, I start off with a bitmap image. I encode it as a jpeg and send it
across the network and pick it up on the other end. Now I have the
jpeg image on the other end as an arrray of bytes and I want to display
it in a picturebox control. How the heck do I convert this byte[] into
a bitmap?
Here is the pertinent code I use to convert it to a jpeg on the server
and send it to client..
....Bitmap workerBmp = new Bitmap(bmp);
MemoryStream memStream = new MemoryStream();
workerBmp.Save(memStream, ImageFormat.Jpeg);
byte[] byteData = memStream.ToArray();
networkStream.Write(byteData, 0, byteData.Length);
So now I pick up the jpeg data on the client and that's where I am
stuck.. how do I get this data into a form that a picturebox can
understand?
I read the data...
while ((bytesRead = networkStream.Read(dataBuffer, totalBytesRead,
dataBuffer.Length - totalBytesRead)) < (dataBuffer.Length -
totalBytesRead))
totalBytesRead += bytesRead;
Now what? I tried dropping the buffer into a MemoryStream and just
instantiating a Bitmap from the stream...i.e..
MemoryStream memStream = new MemoryStream(dataBuffer);
Bitmap bmp = new Bitmap(memStream);
//Image img = Image.FromStream(memStream); Same result if I use this
I get the following Exception..
An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Additional information: Invalid parameter used.
A point in the right direction please..
across the network and pick it up on the other end. Now I have the
jpeg image on the other end as an arrray of bytes and I want to display
it in a picturebox control. How the heck do I convert this byte[] into
a bitmap?
Here is the pertinent code I use to convert it to a jpeg on the server
and send it to client..
....Bitmap workerBmp = new Bitmap(bmp);
MemoryStream memStream = new MemoryStream();
workerBmp.Save(memStream, ImageFormat.Jpeg);
byte[] byteData = memStream.ToArray();
networkStream.Write(byteData, 0, byteData.Length);
So now I pick up the jpeg data on the client and that's where I am
stuck.. how do I get this data into a form that a picturebox can
understand?
I read the data...
while ((bytesRead = networkStream.Read(dataBuffer, totalBytesRead,
dataBuffer.Length - totalBytesRead)) < (dataBuffer.Length -
totalBytesRead))
totalBytesRead += bytesRead;
Now what? I tried dropping the buffer into a MemoryStream and just
instantiating a Bitmap from the stream...i.e..
MemoryStream memStream = new MemoryStream(dataBuffer);
Bitmap bmp = new Bitmap(memStream);
//Image img = Image.FromStream(memStream); Same result if I use this
I get the following Exception..
An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Additional information: Invalid parameter used.
A point in the right direction please..