Note The D3DX (D3DX 9, D3DX 10, and D3DX 11) utility library is deprecated for Windows 8 and is not supported for Windows Store apps.
Note Instead of using this function, we recommend that you use the DirectXTex library, CaptureTexture then SaveToXXXFile (where XXX is WIC, DDS, or TGA; WIC doesn't support DDS and TGA; D3DX 9 supported TGA as a common art source format for games). For the simplified scenario of creating a screen shot from a render target texture, we recommend that you use the DirectXTK library, SaveDDSTextureToFile or SaveWICTextureToFile.
Save a texture to a file.
HRESULT D3DX11SaveTextureToFile( ID3D11DeviceContext *pContext, _In_ ID3D11Resource *pSrcTexture, _In_ D3DX11_IMAGE_FILE_FORMAT DestFormat, _In_ LPCTSTR pDestFile );
A pointer to an ID3D11DeviceContext object.
- pSrcTexture [in]
Pointer to the texture to be saved. See ID3D11Resource.
- DestFormat [in]
- pDestFile [in]
Name of the destination output file where the texture will be saved. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the data type resolves to LPCSTR.
The return value is one of the values listed in Direct3D 11 Return Codes; use the return value to see if the DestFormat is supported.
D3DX11SaveTextureToFile writes out the extra DDS_HEADER_DXT10 structure for the input texture only if necessary (for example, because the input texture is in standard RGB (sRGB) format). If D3DX11SaveTextureToFile writes out the DDS_HEADER_DXT10 structure, it sets the dwFourCC member of the DDS_PIXELFORMAT structure for the texture to DX10 to indicate the prescense of the DDS_HEADER_DXT10 extended header.