Skip to content

EncodeDDSHeader

Chuck Walbourn edited this page Aug 15, 2025 · 1 revision
DirectXTex

Helper functions for creating your own 'magic value' + DDS_HEADER structure. The smallest valid header is 128 bytes. The "DX10" extended header is 148 bytes. If pDestination is nullptr, it will return the amount of memory required.

HRESULT EncodeDDSHeader( const TexMetadata& metadata, DDS_FLAGS flags,
    void* pDestination, size_t maxsize,
    size_t& required);

Parameters

The flags parameter is one of the DDS_FLAGS. By default use DDS_FLAGS_NONE. See DDS-I-O-Functions for more information about these flags.

maxsize is the amount of memory pointed to by pDestination. required is the returned as the amount of used space.

Returns

This function will succeed with an S_OK or will return a HRESULT error code (E_INVALIDARG, E_FAIL, HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), HRESULT_FROM_WIN32(ERROR_CANNOT_MAKE), or HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)).

Exceptions

This function is marked noexcept, and does not throw C++ exceptions.

Further reading

The DDS File Format Lives

DDS Programmer's Guide

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