[求助] D3DXSaveSurfaceToFileInMemory 怎么得到HBITMAP
那个ID3DXBuffer* 不会操作
问题 补充
1 BOOL ScreenShot(LPDIRECT3DDEVICE9 lpDevice, HWND hWnd, TCHAR* fileName)
2 {
3 HRESULT hr;
4
5 // Get adapter display mode
6 D3DDISPLAYMODE mode;
7 if (FAILED(hr = lpDevice->GetDisplayMode(0, &mode)))
8 return hr;
9
10 // Create the surface to hold the screen image data
11 LPDIRECT3DSURFACE9 surf;
12 if (FAILED(hr = lpDevice->CreateOffscreenPlainSurface(mode.Width,
13 mode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surf, NULL))) //注意第四个参数不能是D3DPOOL_DEFAULT
14 {
15 return hr;
16 }
17
18 // Get the screen data
19 if (FAILED(hr = lpDevice->GetFrontBufferData(0, surf)))
20 {
21 surf->Release() ;
22 return hr ;
23 }
24
25 // area to capture
26 RECT *rect = NULL ;
27
28 WINDOWINFO windowInfo ;
29 windowInfo.cbSize = sizeof(WINDOWINFO) ;
30
31 if(hWnd) // capture window
32 {
33 GetWindowInfo(hWnd, &windowInfo) ;
34 rect = &windowInfo.rcWindow ;
35 }
36
37 // Save the screen date to file
ID3DXBuffer* pBuffer=NULL;
38 hr = D3DXSaveSurfaceToFileInMemory (pBuffer, D3DXIFF_BMP, surf, NULL, rect);
后就不会了 pBuffer 怎么转成 HBITMAP