Windows上最快的屏幕捕获方法 [英] Fastest method of screen capturing on Windows

查看:165
本文介绍了Windows上最快的屏幕捕获方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为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上最快的屏幕捕获方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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