Click here to Skip to main content
15,902,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

In a client/server communication,(server side) i load an image in picturebox and i want to send this image to the client and display in its picturebox. How do i do it?
I searched in Google , could not find any where,
please help me


Thanks in advance

Amith
Posted

1 solution

1) Convert the Image property of the PictureBox to a stream of bytes.
2) Send the stream of bytes to the client.
3) Convert the bytes to an Image.
4) Load the Image into a PictureBox.Image property.

Convert Image to byte[] array:

C#
MemoryStream ms = new MemoryStream();
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);
return ms.ToArray();


Convert byte[] array to Image:

C#
MemoryStream ms = new MemoryStream(bytes);
Image returnImage = Image.FromStream(ms);
return returnImage;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900