Fastest way to capture screenshots of a game in C #? (over 20 images per second)

How can I take screenshots on the whole screen of the game very quickly? Something like 20-30 per second? (I want to convert them to video)

[[1]] I tried WMEncoder. The results were that WMEncoder can capture screen and screen areas only in video format (wma) using a set of pre-configured codecs. (29 fps best encoding result) .WMEncoder cannot take screenshots.

[[2]] I tried DirectX:

Surface s = device.CreateOffscreenPlainSurface( Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Format.A8R8G8B8, Pool.SystemMemory); device.GetFrontBufferData(0, s); SurfaceLoader.Save("c:\\Screenshot"+i.ToString()+".bmp", ImageFileFormat.Bmp, s); 

This works like gdi..very slow .... and only works in DirectX 1.0 because SurfaceLoader does not exist in directX 2.0

Another way I read in some post is using:

 s = device.GetBackBuffer(0, 0, Microsoft.DirectX.Direct3D.BackBufferType.Mono); 

but it only takes screenshots in a closing window.

[[3]] I tried to use Taksi (on sourceforge.net) ... but I don't know how to use it in C # and make it work.

Please help me...

+4
source share
1 answer

You really want to connect to DirectX so you can make calls as if you were that game / application. Below are a few sites that do this (most draw extra stuff, but I donโ€™t understand why you couldnโ€™t save the backbuffer every x frames):

http://www.gamedev.net/topic/359794-c-direct3d-hooking-sample/

Disclamer: I have not tried this, so I'm not sure if you can get FPS, however, I would think that this is the fastest method, since you do it efficiently from the inside.

+1
source

Source: https://habr.com/ru/post/1368906/


All Articles