DirectDraw primary surface to jpeg
Hi!
I have a question. I have a basic directdraw application, and i have to capture the screen into a jpeg format. I am using directx 9.0. I am new to directx. Please help, thanks in advance.
arpi
this isnt for directdraw it is for direct3d 9 but it may be helpful
[edited by - eFoDay on March 7, 2004 5:58:01 PM]
void CDirect3D::TakeScreenShot(LPCTSTR pDestFile){ D3DDISPLAYMODE displayMode; LPDIRECT3DSURFACE9 pd3dsFront = NULL; // Get the display mode m_pd3dDevice->GetDisplayMode(0, &displayMode); // Create a surface to hold the front buffer m_pd3dDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pd3dsFront, NULL); // Get the front buffer and save it to a file if( SUCCEEDED( m_pd3dDevice->GetFrontBufferData(0, pd3dsFront) ) ) D3DXSaveSurfaceToFile(pDestFile, D3DXIFF_JPG, pd3dsFront, NULL, NULL); // Release the surface if( pd3dsFront ) pd3dsFront->Release();}
[edited by - eFoDay on March 7, 2004 5:58:01 PM]
Thanks, but i am not using D3D, can i do it without it? How to access the pixel data of the primary surface?(If if can acces the per pixel data ican save it to any format)
use CSurface->Lock(...) to get a pointer to the surface actual bytes. Look in the SDK, this part is explained. And don''t forget to unlock it afterwards.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement