Skip to content

WICTextureLoader

Chuck Walbourn edited this page Aug 16, 2025 · 2 revisions
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.

Direct3D 9

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);

Direct3D 11

See DirectX Tool Kit for DX11.

Direct3D 12

See DirectX Tool Kit for DX12.

Returns

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).

Exceptions

These functions are marked noexcept, and do not throw C++ exceptions.

Remarks

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.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

Architecture

  • x86
  • x64
  • ARM64

For Development

  • 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

Related Projects

DirectXTex Rust bindings

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally