屏幕捕捉的最快速的方法 [英] Fastest method of screen capturing

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

问题描述

我想写为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.

修改:我碰到这篇文章就来了:各种捕获方法屏幕。它把我介绍给做它,做它的方式的DirectX的Windows媒体API的方式。它提到在禁用硬件加速功能可以显着提高捕获应用程序的性能的结论。我很好奇,这是为什么。任何人都可以填补空白失踪我?

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。你可以阅读文章<一个href=\"https://web.archive.org/web/20121205062922/http://www.ring3circus.com/blog/2007/11/22/case-study-fraps/\">here.

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();
}

这篇关于屏幕捕捉的最快速的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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