# Screenshot with Timestamp

## Recommended Posts

ProgrammerDX    395

Hi,

I'm trying to make a screenshot with a timestamp but for some users they sometimes don't get the timestamp on the image :S

From the WndProc I call the CreateScreenshot function which looks as following:

lpD3DDevice->BeginScene();
lpD3DDevice->Clear(ZBUFFER | STENCIL);

draw timestamp as text...

lpD3DDevice->EndScene();
lpD3DDevice->Present(...);

LPDIRECT3DSURFACE9 lpSurface;
lpD3DDevice->GetRenderTarget( 0, &lpSurface );

D3DXSaveSurfaceToFile( fileName, D3DXIFF_PNG, lpSurface, 0, 0 );

lpSurface->Release();


I'm not sure why sometimes this doesn't work. Can it be possible it has to do with the monitor vsync? Like it ignores the new rendered frame..

##### Share on other sites
satanir    1452

So the file is saved correctly, just without the timestamp? Does the timestamp appear in the window?

I know that in Win7, if the windows is not active - for example you are on the lock screen - present calls are being ignored(at least in DX10+).

##### Share on other sites
ProgrammerDX    395

So the file is saved correctly, just without the timestamp? Does the timestamp appear in the window?

I know that in Win7, if the windows is not active - for example you are on the lock screen - present calls are being ignored(at least in DX10+).

The window isn't inactive or locked

The users sees the timestamp in-game, its just not saved on the image

##### Share on other sites
cozzie    5029

Maybe a bit simple, but are you 100% sure the timestamp is 'drawn' onto the same surface/ target where the scene is? (which you save/ capture)

##### Share on other sites
ProgrammerDX    395

Yeah, remember it works for most but not all users.

I found this piece of code and I'll try it in next patch to see f it works:  (first answer)

http://stackoverflow.com/questions/5069104/fastest-method-of-screen-capturing

In that code, instead of calling D3DXSaveSurfaceToFile() directly on the GetRenderTarget() surface, it first creates an Offscreen Surface and copies the Render Target to the Offscreen Surface using GetRenderTargetData().

I don't have any idea why that would be of any benefit over what I'm doing.. but let's see...

Edited by ProgrammerDX

##### Share on other sites
ProgrammerDX    395

It didn't make any difference...