well, im wondering how i could take a screenshot of the DirectX window and save it to a bmp (for simplicity). At the moment, heres the code i use:
Code:
bool TakeScreenShot(IDirect3DDevice9 *Device, char *FileName, int ScreenX, int ScreenY)
{
IDirect3DSurface9 *FrontBuffer;
bFailed = false;
HRESULT Result;
Result = Device->CreateOffscreenPlainSurface(ScreenX, ScreenY, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &FrontBuffer, NULL);
if (Result != D3D_OK)
{
//FrontBuffer->Release(); Thanks Magos
return false;
}
Result = Device->GetFrontBufferData(0, FrontBuffer);
if (Result != D3D_OK)
{
FrontBuffer->Release();
return false;
}
Result = D3DXSaveSurfaceToFile(FileName, D3DXIFF_BMP, FrontBuffer, NULL, NULL);
if (Result != D3D_OK)
{
FrontBuffer->Release();
return false;
}
FrontBuffer->Release();
return true;
}
it works fine, but its EXTREMELY slow, i tried putting it in a thread, and i get a deformed image.
so, i was wondering, would it be faster/better to do this using GDI? ie. bitblt into a memory hdc and go from there? or is this the only way?
Thanks in advance.