2

I am capturing images for a video recording. and it's working well when resolution is less than or equal to 1920 X 1080.

When I capture images with a resolution of 3840 X 2160 it takes around 200 milliseconds.

using (Bitmap bmp = new Bitmap(CaptureRegion.Width, CaptureRegion.Height))
{
    using (Graphics g = Graphics.FromImage(bmp))
    {
        g.CopyFromScreen(CaptureRegion.Left, CaptureRegion.Top, 0, 0, bmp.Size);
    }
    Bitmap resized = new Bitmap(bmp, new Size(1920, 1080));
    playerFrame(resized);
}
Draken
  • 3,134
  • 13
  • 34
  • 54
Ankur Tripathi
  • 471
  • 2
  • 16
  • 11
    When you profiled your code, which was the slow part? – mjwills Jul 26 '18 at 12:57
  • 2
    Why do you resize all pictures to 1920x1080 after you capture them? Is that really needed? – bassfader Jul 26 '18 at 12:59
  • 1
    For capturing video there is typically a special hardware support and technologies (e.g. [ShadowPlay](https://www.nvidia.com/en-us/geforce/geforce-experience/shadowplay/)). You are doing it the most naive way and expecting it to perform for 4k.. – Sinatr Jul 26 '18 at 12:59
  • Possible duplicate of [C# Screen streaming program](https://stackoverflow.com/questions/34421447/c-sharp-screen-streaming-program) – Jeff Brower Jul 26 '18 at 13:05
  • 2
    Capturing the screen by using `Graphics.FromImage()` is the slowest possible way to do this, as it grabs full images *after* the screen was rendered, without any benefit from the graphic card's abilities. Think 1995 in performance, CPU usage. Windows has DirectX for video, games *and* screen capturing purposes. – Panagiotis Kanavos Jul 26 '18 at 13:05

0 Answers0