-
Notifications
You must be signed in to change notification settings - Fork 463
ScreenGrab
DirectXTex |
---|
A Direct3D 2D texture save routine for generating a "screenshot" from a render target texture. There is a function that will dump the 2D texture to a .DDS
file, and another that will write using WIC (BMP
, JPEG
, PNG
, TIFF
, GIF
, JPEG-XR / HD Photo, or other WIC supported file container).
These writers do not support array textures, 1D textures, 3D volume textures, cubemaps, or cubemap arrays. The ScreenGrab module is really designed to make a quick and light-weight solution for capturing screenshots at runtime. For more complex textures, see DirectXTex CaptureTexture.
MSAA textures are resolved before being written.
This is the standalone version of these functions. They are also integrated into the DirectX Tool Kit.
HRESULT SaveDDSTextureToFile(
LPDIRECT3DSURFACE9 pSource,
const wchar_t* fileName);
HRESULT SaveWICTextureToFile(
LPDIRECT3DSURFACE9 pSource,
REFGUID guidContainerFormat,
const wchar_t* fileName,
const GUID* targetFormat = nullptr,
std::function<void (IPropertyBag2*)> setCustomProps = nullptr);
See DirectX Tool Kit for DX11.
See DirectX Tool Kit for DX12.
These functions will succeed with an S_OK
or will return a HRESULT error code (E_INVALIDARG
, E_OUTOFMEMORY
, E_FAIL
, E_POINTER
, E_UNEXPECTED
, HRESULT_FROM_WIN32(ERROR_INVALID_DATA)
, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)
, or in some cases an HRESULT_FROM_WIN32
result from a Win32 function failure).
These functions are marked noexcept
, and do not throw C++ exceptions.
These modules are not included in the DirectXTex.lib. To use them directly add the appropriate .cpp and .h file from the ScreenGrab
folder to your project -or- use the DirectX Tool Kit.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v20
- GCC 10.5, 11.4, 12.3, 13.3, 14.2
- MinGW 12.2, 13.2
- CMake 3.21
DirectX Tool Kit for DirectX 11