DirectDraw primary surface to jpeg

Started by
3 comments, last by arpi23 20 years, 1 month ago
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
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]
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)
Surface->GetPixelFormat() to get the current surface pixel format (8, 16, 24, 32)...
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