I am implementing a feature that will take screen shot repeatedly and output dirty rectangles between 2 different shots then send re-draw the screen in a window.
I can get it running between 20~30FPS currently. It is already acceptable. But then I made a benchmark and measured its performance. Found out that the Graphics.CopyFromScreen() takes up to 50% of the processing time. (Yep. Even in the worst case, it still takes longer than find all the dirty rectangles) Then I used native API implementation BitBlt() and get no improvement.
I know there may not be any practical reasons to make it any faster than 30FPS in this case. I am just wondering, is there any faster way to take a screen shot?
Thanks.
解决方案
This is very similar to a question asked several years ago: Here. That question was whether directx's capturing abilities could be used to get better performance.
The consensus was that it probably wouldn't provide any performance increase, TightVNC does it very quickly by cheating. It uses a driver that doesn't have to use the API that (presumably) .NET is using.
At some point I recall looking at the source code for Camstudio and I believe they use directx's capturing capabilities. I don't think you can push that much past 30 fps, and most of the time not even that. I'm not sure if that is a problem with the hooks camstudio uses to figure out when something has changed or the actual capture mechanism.