C#这是采取了截屏的最快方法? [英] C# Which is the fastest way to take a screen shot?
问题描述
我在执行一项功能,将屏幕截图反复输出肮脏的矩形2种不同的镜头之间,然后发送重新绘制屏幕在一个窗口。
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.
我可以得到它在20〜30FPS之间运行当前。它已经是可以接受的。但后来我做了一个基准,衡量其性能。发现上述 Graphics.CopyFromScreen()
占用的处理时间的50%。 (是的,即使在最坏的情况下,它仍然比找到所有的脏矩形需要更长的时间),然后我用原生API实现的BitBlt()
并没有得到改善。
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.
我知道有可能没有任何实际的理由,使其比任何30FPS快于这种情况。我只是想知道,有没有更快的方式采取了截屏?
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?
感谢。
推荐答案
这是非常类似的问题问了几个年前:<一href="http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/aac8265e-d693-4cd1-ab5e-a7f0ab2a212d"相对=nofollow>这里。这个问题是,是否的DirectX的捕获能力,可以用来获得更好的性能。
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.
的共识是,它可能不会提供任何的性能提升,TightVNC的做它很快被欺骗。它使用不具有使用该(presumably).NET是使用API的驱动。
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.
在某些时候,我记得查看源$ C $下的Camstudio ,我相信他们使用DirectX的捕获能力。我不认为你可以把这么多过去的每秒30帧,并且大部分时间甚至没有。我不知道这是用钩子有问题的Camstudio使用弄清楚当事情已经改变或实际捕获机制。
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.
这篇关于C#这是采取了截屏的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!