| 
 | 
 
我想获得D3D9开发的三维动画的屏幕数据(即屏幕截图),希望获得前台或者后台缓冲区的屏幕数据得到图像的颜色值矩阵,我自己做一个但无法获取。希望指点: 
 (1)   
LPDIRECT3DDEVICE9 m_pDevice; 
   IDirect3DSurface9 *surface=NULL; 
  m_pDevice->CreateOffscreenPlainSurface(  400,300,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);   
    HRESULT hr=m_pDevice->GetFrontBufferData(0,surface); 
    char*  file_name = "d:\\pic.bmp"; 
    D3DXSaveSurfaceToFile(file_name,D3DXIFF_BMP,surface,NULL,NULL); 
    surface->Release(); 
(1)生成的图像没有获取到屏幕图像 
 
或者:(2) 
         IDirect3DSurface9 *surface=NULL; 
         D3DSURFACE_DESC  surfaceDesc; 
         D3DLOCKED_RECT lockedRect; 
         surface->GetDesc(&surfaceDesc); 
        surface->LockRect(&lockedRect,0,0); 
        DWORD *imageData = (DWORD*)lockedRect.pBits; 
         DWORD   clor[400][300]; 
        for(UINT i=0;i < surfaceDesc.Height;i++) 
                for(UINT j=0;j < surfaceDesc.Width;j++) 
                { 
                        int index = i*lockedRect.Pitch/4+j; 
                        clor[j]=imageData[index]; 
                } 
                surface->UnlockRect(); 
                surface->Release() 
(2)在调试时surface->GetDesc(&surfaceDesc);没有获取值,程序出错,希望指教。 |   
 
 
 
 |