This function runs more faster than D3DXSaveSurfaceToFile() function.
Definition
HRESULT CaptureImage(LPCWSTR pwszFilePath, INT nFileType, INT nQuality, INT nCaptureMode,
BOOL bIncludeCursor, LONG_PTR lpParam1)
Parameters
LPCWSTR pwszFilePath
[in] Path where the JPEG image will be placed in. This path must be full path with extension.
INT nFileType
[in] Specifies image file type.
BCAP_IMAGE_BMP
Save as BMP format. It doesn't compress image data.
BCAP_IMAGE_JPG
Save as JPEG format. It compresses image data. Also JPEG format is lossy format.
It doesn't compress image data.
BCAP_IMAGE_PNG
Save as PNG format. On capturing D3D9 surface, 32bpp(bit per pixel) PNG image is created if surface can handle alpha channel(D3DFMT_A8R8G8B8). Otherwise 24bpp PNG file is created.
INT nQuality
[in] Specifies image quality(compression rate) when saving JPEG file. This value can range from 1 ~ 100. Usually 80 is reasonable value to get a quality image.
INT nCaptureMode
[in] Decide which surface to capture.
BCAP_MODE_D3D9
BCAP_MODE_D3D9_SCALE
BCAP_MODE_D3D9_SWAPCHAIN
capture D3D9 surface.
BCAP_MODE_D3D8
capture D3D8 surface.
BCAP_MODE_D3D10
capture D3D10 surface.
BCAP_MODE_GL
capture OpenGL surface.
BCAP_MODE_DDRAW7
capture DDRAW7 surface.
BCAP_MODE_D3D11
capture D3D11 surface.
BOOL bIncludeCursor
[in] Specifies whether to include or not include the mouse cursor image.
LONG_PTR lpParam1
[in] Pass device interface pointer according to nCaptureMode mode.
BCAP_MODE_D3D9 : Pointer of Direct3D9 interface to be captured(IDirect3DDevice9*).
BCAP_MODE_D3D9_SCALE : Pointer of Direct3D9 interface to be captured (IDirect3DDevice9*).
BCAP_MODE_D3D9_SWAPCHAIN : Pointer of Direct3D9 swapchain interface to be captured (IDirect3DSwapChain9*).
BCAP_MODE_D3D8 : Pointer of Direct3D8 interface to be captured(IDirect3DDevice8*).
BCAP_MODE_D3D10 : Pointer of IDXGISwapChain interface to be captured(IDXGISwapChain*).
BCAP_MODE_GL : If Open GL is captured, No need to set the parameter(NULL).
BCAP_MODE_DDRAW7 : Pointer of DDRAW7 Backbuffer interface to be captured (IDirectDrawSurface7*).
BCAP_MODE_D3D11 : Pointer of IDXGISwapChain interface to be captured(IDXGISwapChain*).