A lightweight DirectX screen grabber library, using the Windows Desktop Duplication API, based on the NVIDIA Video SDK samples.
The following steps illustrate how to use the library:
- Call the
create()
function, which returns a pointer to the created grabber instance. - Call either
grab()
orsave()
as many times as required. - Call
release()
to free resources.
The grab()
returns a pointer to a byte array image. The format required can be specified through the aguments to the function. The two formats currently supported are 24-bit RGB and 96-bit Darknet. Further details are provided below.
The save()
function saves the captured screenshot to a PPM file.
When the RGB format is specified, the byte array returned is in row-major format, with each channel stored as one byte [R, G, B, ...].
When the Darknet format is specified, the byte array returned should be interpreted as an array of floats. Each channel is stored successively, with each entry stored as one float [R, R, R, ..., G, G, G, ..., B, B, B].