Requires a C/C++ code to screen capture in a Windows environment

Asked 2 years ago, Updated 2 years ago, 30 views

We are producing a screen casting program for Windows to film game videos.

Speed is important. I'm looking for a way other than GDI, but I can't find the relevant information well.

Which way should I look?

windows c c++

2022-09-22 22:18

1 Answers

How about this code

void dump_buffer()
{
   IDirect3DSurface9* pRenderTarget=NULL;
   IDirect3DSurface9* pDestTarget=NULL;
     const char file[] = "Pickture.bmp";
   // Verify that it is OK.
   if (Device == NULL)
      return;

   // Obtained render target
   HRESULT hr = Device->GetRenderTarget(0, &pRenderTarget);
   // Obtained current adapter display mode
   //hr = pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddisplaymode);

   // Create destination surface
   hr = Device->CreateOffscreenPlainSurface(DisplayMde.Width,
                         DisplayMde.Height,
                         DisplayMde.Format,
                         D3DPOOL_SYSTEMMEM,
                         &pDestTarget,
                         NULL);
   // Copy render target to destination surface
   hr = Device->GetRenderTargetData(pRenderTarget, pDestTarget);
   // Save to bitmap file
   hr = D3DXSaveSurfaceToFile(file,
                              D3DXIFF_BMP,
                              pDestTarget,
                              NULL,
                              NULL);

   // Clean up before exiting
   pRenderTarget->Release();
   pDestTarget->Release();
}


2022-09-22 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.