Image transfer

I am new to C#.

I have to develop a simple client server application that takes screenshot (print sceen) of the client's desktop and just sends it to the server continuously every 3 seconds.

Can anybody develop a sample appln and help me out.

Thnx in advance for any help



Answer this question

Image transfer

  • KingKarter

    Have you verified that the buffer you are using to receive the data is large enough to hold all of the data that is being transmitted and that data is not being truncated

    Mark.



  • NewDeveloper83291

    the same error with me ...

    my program is a vidio conference and I recieve image with this code:

    while (true)

    {

    serverSocket.Receive(data);

    MemoryStream mem = new MemoryStream(data);

    desktopImage.Image = Image.FromStream(mem);

    }

    and the Exception in "desktopImage.Image = Image.FromStream(mem); " ...

    I am sure that no missing bytes throught sending progress ...

    any suggest

    any link for an example about vidio conference works


  • SpokaneDude

    I use winApi to get the desktop picture :

    hBitmap = PlatformInvokeGDI32.CreateCompatibleBitmap(hDC, size.cx, size.cy);

    then I turn it to a byte stream :

    desktopImg.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg);

    byte[] img = mem.GetBuffer();

    serverSocket.Send(img);

    serversocket is a multicast socket ...

    I tried to show the image in a picture box befor sending it :

    pic.image=hBitmap ;

    and everything is ok


  • hrubesh

    Hi,

    are you sending just the pixel data or the pixel data and the bitmap header information like the width height etc across the stream

    Mark.



  • bergen

    Hi,

    you can use Graphics.CopyFromScreen http://msdn2.microsoft.com/ru-ru/library/6yfzc507(VS.80).aspx to get the desktop image, after that you will need to send the data, you could create a web service or a direct port connection.

    Mark.



  • mlawton

    I m able to capture the screen, but the problem is in continuously sending and receiving the images.

    In particular, i m getting a MemoryStream error. It works once in a blue moon and gives a typical invalid parameter error while trying to receive the image.

    MemoryStream ms = new MemoryStream(buf);

    Image img = Image.FromStream(ms);//THIS IS WHERE THE ERROR OCCURS


  • carp

    The error indicates that you are missing some bytes before you compose the image.

    Make sure you have received all the sent bytes only when you are composing the image again.

    Best Regards,

    Rizwan aka RizwanSharp



  • Image transfer