-
Notifications
You must be signed in to change notification settings - Fork 463
WICTextureLoader
DirectXTex |
---|
A Direct3D 2D texture loader that uses Windows Imaging Component (WIC) to load a bitmap (BMP
, JPEG
, PNG
, TIFF
, GIF
, HD Photo, or other WIC supported file container), resize if needed based on the current feature level (or by explicit parameter), format convert to a standard DXGI format if required, and then create a 2D texture. This optionally supports auto-generated mipmaps.
This loader does not support array textures, 1D textures, 3D volume textures, cubemaps, or cubemap arrays. For these scenarios, use the .DDS
file format and DDSTextureLoader instead.
DDSTextureLoader is recommended for fully "precooked" textures for maximum performance and image quality, but this loader can be useful for creating simple 2D texture from standard image files at runtime.
This is the standalone version of these functions. They are also integrated into the DirectX Tool Kit.
HRESULT CreateWICTextureFromMemory(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* wicData,
size_t wicDataSize,
LPDIRECT3DTEXTURE9* texture,
size_t maxsize = 0,
WIC_LOADER_FLAGS loadFlags = WIC_LOADER_DEFAULT);
HRESULT CreateWICTextureFromFile(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* fileName,
LPDIRECT3DTEXTURE9* texture,
size_t maxsize = 0,
WIC_LOADER_FLAGS loadFlags = WIC_LOADER_DEFAULT);
// Extended version
HRESULT CreateWICTextureFromMemoryEx(
LPDIRECT3DDEVICE9 d3dDevice,
const uint8_t* wicData,
size_t wicDataSize,
size_t maxsize,
DWORD usage,
D3DPOOL pool,
WIC_LOADER_FLAGS loadFlags,
LPDIRECT3DTEXTURE9* texture);
HRESULT CreateWICTextureFromFileEx(
LPDIRECT3DDEVICE9 d3dDevice,
const wchar_t* fileName,
size_t maxsize,
DWORD usage,
D3DPOOL pool,
WIC_LOADER_FLAGS loadFlags,
LPDIRECT3DTEXTURE9* texture);
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_NOT_SUPPORTED)
, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)
, or an error code from Windows Imaging Component).
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 WICTextureLoader
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 opencode@microsoft.com 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