1

I am writing a program similar to TeamViewer. But I have a problem that the screen resolution is too big. Below is a how I am generating the image from the screen.

byte[] ScreenShut()
{
    Bitmap bmp = new  Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);

    Graphics gr = Graphics.FromImage(bmp);
    bmp.SetResolution(96.0F,96.0F);
    gr.CopyFromScreen(0, 0, 0, 0, new Size(bmp.Width, bmp.Height));
    MemoryStream ms = new MemoryStream();
    bmp.Save(ms, ImageFormat.Png);
    return ms.GetBuffer();
}

How can I reduce the quality of the incoming picture?

Bijington
  • 3,661
  • 5
  • 35
  • 52
  • This article may help you: [How to change resolution (DPI) of an image?](http://stackoverflow.com/questions/4427059/how-to-change-resolution-dpi-of-an-image). – WPInfo Mar 13 '17 at 08:09

2 Answers2

0

Save it as jpg 8 bit using this

public Bitmap(
    int width,
    int height,
    PixelFormat format
)
Marco Salerno
  • 5,131
  • 2
  • 12
  • 32
0

I am writing a program similar to TeamViewer

I'll assume you are referring to the RDP/desktop sharing aspects.

Your problem is that you are not taking into account any prior frames so there is much erroneous data being transmitted. Generally, not a great deal of the screen changes from moment to moment. You need to compare prior frames to the current frame to determine what has changed and only send the deltas. Therefore your problem is essentially that of how to stream moving images or consecutive frames in a reasonably fast fashion.

The problem can be solved with any streaming video solution. Perhaps H.264?

You will find that video codecs don't just work on the current frame but also prior frames. Thus you can think of the screen being a slice moving through time of a much larger rectangular prism. So simply to solve it in a 2D fashion like trying to reduce the bit-depth; spacial resolution won't be sufficient.