Windowed Screenshots in DX 9
I''ve succesfully used GetFrontBufferData(...) to get a full screen screenshot. I''d like to set my program up to also be capable of taking windowed screenshots. How should I do that?
Thanks
If you''re using D3DX, their SaveSurfaceToFile function
can be passed the rectangle to save from the surface. Use
your window''s rectangle.
can be passed the rectangle to save from the surface. Use
your window''s rectangle.
This is what i use for the full screen shots. I understand that the window''s rect can be used as the last parameter in D3DXSaveSurfaceToFile, but what do I do as far ss the SrcSurface goes since I can''t use GetFrontBufferData?
Thanks.
Thanks.
void CMain::TakeScreenShot()//, int screenx, int screeny){ char file_name[40]; FILE* f; for(int i=0;i<999;i++) { // build the filename sprintf(file_name, "Screenshots\\Buzzster%i.jpg\0", i); f = fopen(file_name, "r"); if( f == NULL) break; else fclose( f ); } LPDIRECT3DSURFACE9 frontbuf=NULL;//buffer to store copy of front buffer //Creates the offscreen surface m_pD3DDevice->CreateOffscreenPlainSurface(640, 480, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &frontbuf, NULL); //Copy the front buffer into the surface HRESULT hr = m_pD3DDevice->GetFrontBufferData(NULL, frontbuf); //error checking if(hr != D3D_OK) { //do error handling etc... Log("Could not take screenshot.\n"); frontbuf->Release(); //release the surface so there is no memory leak return; } //Writes the image to a file //the last 2 params are NULL because we want the entire front buffer and no palette D3DXSaveSurfaceToFile(file_name, D3DXIFF_JPG, frontbuf, NULL, NULL); //release the surface so there is no memory leak frontbuf->Release();}
I don''t understand your problem..?
If your code currently saves the entire screen correctly, just
pass your window''s client area as the rectangle. D3DX will cut
that rectangle out of your surface and save it alone to file.
If your code currently saves the entire screen correctly, just
pass your window''s client area as the rectangle. D3DX will cut
that rectangle out of your surface and save it alone to file.
|
|
|
|
|
|
v
-UltimaX-
|Designing A Screen Shot System|
"You wished for a white christmas... Now go shovel your wishes!"
|
|
|
|
|
v
-UltimaX-
|Designing A Screen Shot System|
"You wished for a white christmas... Now go shovel your wishes!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement