• Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectDraw primary surface to jpeg

This topic is 5096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
this isnt for directdraw it is for direct3d 9 but it may be helpful


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]

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement