我想为 Windows 平台编写一个截屏程序,但不确定如何截屏.我知道的唯一方法是使用 GDI,但我很好奇是否有其他方法可以解决这个问题,如果有,哪种方法产生的开销最少?速度是重中之重.
I want to write a screencasting program for the Windows platform, but am unsure of how to capture the screen. The only method I'm aware of is to use GDI, but I'm curious whether there are other ways to go about this, and, if there are, which incurs the least overhead? Speed is a priority.
截屏程序将用于录制游戏画面,不过,如果这确实缩小了选择范围,我仍然愿意接受超出此范围的任何其他建议.毕竟,知识还不错.
The screencasting program will be for recording game footage, although, if this does narrow down the options, I'm still open for any other suggestions that fall out of this scope. Knowledge isn't bad, after all.
编辑:我看到这篇文章:捕获屏幕的各种方法一>.它向我介绍了执行此操作的 Windows Media API 方式和执行此操作的 DirectX 方式.它在结论中提到禁用硬件加速可以显着提高捕获应用程序的性能.我很好奇这是为什么.谁能帮我填一下缺失的空格?
Edit: I came across this article: Various methods for capturing the screen. It has introduced me to the Windows Media API way of doing it and the DirectX way of doing it. It mentions in the Conclusion that disabling hardware acceleration could drastically improve the performance of the capture application. I'm curious as to why this is. Could anyone fill in the missing blanks for me?
编辑:我读到诸如 Camtasia 之类的截屏程序使用它们自己的捕获驱动程序.有人能给我一个关于它是如何工作的以及为什么它更快的深入解释吗?我可能还需要有关实施此类内容的指导,但我确信无论如何都有现有文档.
Edit: I read that screencasting programs such as Camtasia use their own capture driver. Could someone give me an in-depth explanation on how it works, and why it is faster? I may also need guidance on implementing something like that, but I'm sure there is existing documentation anyway.
此外,我现在知道 FRAPS 如何记录屏幕.它挂钩底层图形 API 以从后台缓冲区读取.据我了解,这比从前端缓冲区读取要快,因为您是从系统 RAM 读取,而不是从视频 RAM 读取.您可以阅读文章 这里.
Also, I now know how FRAPS records the screen. It hooks the underlying graphics API to read from the back buffer. From what I understand, this is faster than reading from the front buffer, because you are reading from system RAM, rather than video RAM. You can read the article here.
这是我用来收集单帧的,但如果你修改它并保持两个目标一直打开,那么你可以将它流式传输"到磁盘使用静态计数器作为文件名.- 我不记得我在哪里找到的,但它已被修改,感谢谁!
This is what I use to collect single frames, but if you modify this and keep the two targets open all the time then you could "stream" it to disk using a static counter for the file name. - I can't recall where I found this, but it has been modified, thanks to whoever!
void dump_buffer()
{
IDirect3DSurface9* pRenderTarget=NULL;
IDirect3DSurface9* pDestTarget=NULL;
const char file[] = "Pickture.bmp";
// sanity checks.
if (Device == NULL)
return;
// get the render target surface.
HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
// get the current adapter display mode.
//hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);
// create a destination surface.
hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
DisplayMde.Height,
DisplayMde.Format,
D3DPOOL_SYSTEMMEM,
&pDestTarget,
NULL);
//copy the render target to the destination surface.
hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
//save its contents to a bitmap file.
hr = D3DXSaveSurfaceToFile(file,
D3DXIFF_BMP,
pDestTarget,
NULL,
NULL);
// clean up.
pRenderTarget->Release();
pDestTarget->Release();
}
这篇关于Windows 上最快的屏幕捕获方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!