1

Short version:

I need a C# function to paste into my code, that takes a screenshot of a rectangle (x, y, w, l) of the screen using DXGI (assuming it's referenced), because I believe it will do better than Graphics.CopyFromScreen.

Long version:

I'm writing a game macro in C#, and it uses information from the screen to determine what to do. Specifically, it's repeatedly taking screenshots as Bitmaps and performs a bunch of GetPixels. Right now I'm using Graphics.CopyFromScreen to get the images, and it's very inconvenient for me, since taking screenshots of an entire screen takes too long, and working with partial screenshots is a whole other task (which I'm currently doing, but I believe it can be done easier).

I tried comparing CopyFromScreen to unmanaged BitBlt, both whole screen and small area of it, and the performance is roughly same (I feel like it's the same thing under the hood). Then I found out about SharpDX and screen manipulations related to it. There are a lot of projects that take video from the screen, and a few that take screenshots, but I can't understand the code enough to integrate it into my project. I'm hoping someone can help.

As a side note, the app that I'm taking pictures of uses OpenGL, if that helps.

  • Have a look at [this thread](https://stackoverflow.com/questions/6812068/c-sharp-which-is-the-fastest-way-to-take-a-screen-shot) where you will find a few good ideas for your case. – Kate Orlova Jun 17 '19 at 20:14
  • So if they're correct, using DX won't make it any faster. I'll have to settle for that if nothing else comes up. – TheLeftExit Jun 17 '19 at 20:36
  • To take game (or other apps) screenshots, I usually use [D3DXSaveSurfaceToFile](https://learn.microsoft.com/en-us/windows/desktop/direct3d9/d3dxsavesurfacetofile) – Castorix Jun 18 '19 at 15:50

0 Answers0