Capture Game Screen Shots Through Code [Solved]

Posts 13 of 3 · Page 1 of 1
Capture Game Screen Shots Through Code [Solved]
Hi guys,

could anyone please list a few ways to take screenshots from C code that will work with "normal" games as well as with 3d games?

I am mainly interested in capturing pixels from a DirectX game.

Thanks in advance.
Code:
HRESULT CopyScreen(LPDIRECT3DDEVICE8 pDevice, char *szFileName)
{
	HRESULT hr;

	D3DDISPLAYMODE mode;
	if (FAILED(hr=pDevice->GetDisplayMode(&mode)))
		return hr;

	LPDIRECT3DSURFACE8 pSurface;
	if (FAILED(hr=pDevice->CreateImageSurface(mode.Width, mode.Height, D3DFMT_A8R8G8B8,&pSurface)))
		return hr;

	if (FAILED(hr=pDevice->GetFrontBuffer(pSurface)))
	{
		pSurface->Release();
		return hr;
	}

	hr=D3DXSaveSurfaceToFile(szFileName, D3DXIFF_BMP, pSurface, NULL, NULL);

	pSurface->Release();

	return hr;
}

CopyScreen(pDevice, "C:\\Screenshot.bmp");
Thanks Hell_Demon
Posts 13 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?