Image transfer

  • Thread starter Thread starter Clayton
  • Start date Start date
C

Clayton

Hi all,

Can anyone give me a brief description of what I need to do to
transfer an image from a client/server application using C#? When I
googled, I found that first I need to convert the image into a stream
and than tranfser it. Is that right? How I'm going to convert back the
stream to an image? Using deserialization? If possible point out in
steps what I need to do!

Thanks a lot in advanced,
Clayton
 
Hello Clayton,
Can anyone give me a brief description of what I need to do to
transfer an image from a client/server application using C#? When I
googled, I found that first I need to convert the image into a stream
and than tranfser it. Is that right? How I'm going to convert back the
stream to an image? Using deserialization? If possible point out in
steps what I need to do!

Well, it depends. "Convert an image into a stream" - that doesn't say a
lot. An image is a block of bytes, basically, and you can easily send
those bytes, one by one, through a network connection, put them back
together on the other side and get the same image.

In practice, you may need to encode the byte stream somehow, according to
the needs of the communications protocol you're using - base64 would be
one example of such an encoding. When decoding the byte stream on the
other side, you would then have to use the corresponding algorithm of
course.


Oliver Sturm
 
If you want to transfer image you need to convert your image into filestream,
yes it is correct and code is as follows

FileStream f = new FileStream(@"c:\image.jpg", FileMode.Open);
You will need to import System.IO namcespace also. If you have image then
first save it to disk usaing Image.save("Path") function and then read it in
filestream.
and you can send this stream to server

Now on the recieving end you will regenerate the image from stream as follows

Bitmap img=new Bitmap(streamBoject);

so it is simple just pass the filestream to the constructor for bitmap
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top