   Screen Capture Fails
  I've been working on a DirectX 9.0 (I believe DirectX 9.0a) + Windows API application (with menus, dialogs, and the like). I'm trying to capture a screen shot of either the Desktop or the Window area. I've create a basic function that stuffs a IDirect3DSurface9 with Offscreen buffer data, then I try to save the Surface to a file using DirectX's function: D3DXSaveSurfaceToFileA. Every time I try it, it seemingly works, but the picture always comes out garbled. Here is the code:int SnapScreenShot(void){IDirect3DSurface9* SnapShotBuffer = NULL;static HRESULT Answer; // Designate a spot to take the shotd3dDevice->CreateOffscreenPlainSurface(256, 256, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &SnapShotBuffer, NULL);// Get the screen ARGB bitsAnswer = d3dDevice->GetFrontBufferData(0, SnapShotBuffer);// Calculate answersif(Answer == D3D_OK)MessageBox(NULL, "Front Buffer was stored!", "", MB_OK);if(Answer == D3DERR_DEVICELOST)MessageBox(NULL, "Front Buffer was not stored!", "", MB_OK);if(Answer == D3DERR_INVALIDCALL)MessageBox(NULL, "Front Buffer was not stored! D3DERR_INVALIDCALL", "", MB_OK);  // If all is well - Save the data outif(D3DXSaveSurfaceToFile("Screenshot0001.bmp", D3DXIFF_BMP,  SnapShotBuffer, NULL, NULL)  == D3D_OK) MessageBox(NULL, "Screen shot saved!", "Good report", MB_OK);else   MessageBox(NULL, "Screen shot failed to save...", "ERROR", MB_OK);   // Release after we are done using it.SnapShotBuffer->Release();   // return OKreturn 1;}I'm also doing this in "windowed mode". I tried changing the code around, but I couldn't get the picture to save un-garbled.Thanks Guys for the HELP!   
  I'm not sure about this, but any time I use my snapshot function it had to be prior to calling present on the backbuffer (I'm not sure where you call the function, so it may or may not be the case for you...).Just for a reference, here's my function that records the back buffer (as opposed to your front buffer version)://--------------------------------------------------------------------------------void CRendererDX9::SaveScreenShot( std::string& filename ){static int iScreenNum = 100000;iScreenNum++;std::stringstream out;out << iScreenNum;IDirect3DSurface9* BackBuffer = NULL;m_pDevice->GetRenderTarget(0, &BackBuffer);std::string name = out.str();name = filename + name + std::string(".bmp"); //out.str() + D3DXSaveSurfaceToFile( name.c_str(), D3DXIFF_BMP, BackBuffer, NULL, NULL );if (BackBuffer != NULL)   BackBuffer->Release();}//--------------------------------------------------------------------------------;  Hey Thanks!!!I would have never thought of that, because of "Microsoft's misleading" help files. Follow the link to see what I mean.Microsoft Website LibraryLook at the "Remarks" on the bottom that read:This method is the only way to capture an antialiased screen shot. What type of misinformation is that! but anyway, Thanks Again Jason!   ;Quote:Original post by Photon ManHey Thanks!!!I would have never thought of that, because of "Microsoft's misleading" help files. Follow the link to see what I mean.Microsoft Website LibraryLook at the "Remarks" on the bottom that read:This method is the only way to capture an antialiased screen shot. What type of misinformation is that! but anyway, Thanks Again Jason!That's because if your backbuffer is antialiased, you won't be able to use that method, and you'll have to use GetFrontBufferData.   ;  Thanks Steve for shining some light back on microsoft... The snapshot backbuffer code did the trick for me, except now you've increased my pondering on how you'd use the GetFrontBufferData function. Does anyone have a miracle? I've read some of your replies to other posts, Steve, and you've helped me A lot, so Thanks!   