C# 哪种截屏方式最快? [英] C# Which is the fastest way to take a screen shot?

查看:80
本文介绍了C# 哪种截屏方式最快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施一项功能,该功能将重复拍摄屏幕截图并在 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?

谢谢.

推荐答案

这与几年前提出的问题非常相似:这里.这个问题是 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 通过作弊很快做到了.它使用的驱动程序不必使用(大概).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.

在某些时候,我记得查看 Camstudio 的源代码,我相信他们使用了 Directx 的捕获功能.我不认为你可以将 30 fps 的速度推到 30 fps 以上,而且大多数时候甚至不能超过 30 fps.我不确定这是否是 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆