Skip to content

Image formats

Chuck Walbourn edited this page Jan 19, 2024 · 28 revisions

The DirectXTex library primarily uses Windows Imaging Component (aka WIC) to perform image I/O, but includes a custom codec for DDS, HDR, and TGA files as well as optional support for EXR. A complete, detailed description of image file formats is well beyond the scope of this wiki. This page does provide a quick overview of the common formats the library is designed to read/write.

BMP (Windows Bitmap Format)

The BMP file format is a long-lived Windows-specific format for images which is supported by a built-in WIC codec. See Wikipedia for more details.

There is an unofficial extension of BMP for DXTn compressed data that was created primarily for use by the Microsoft flight simulator team. This format is not widely useful enough to support in the DirectXTex library, but texconv supports reading them.

To aid in debugging, here is a simple console program for dumping out the content of a BMP header in a human-readable form.

DDS (DirectDraw Surface)

The DDS file format is not so much an image format as a "Direct3D resource" container for textures. It can contain data in all DXGI formats, 1D textures, 2D textures, 1D & 2D texture arrays, cubemaps, cubemap arrays, and volume maps. For more details, see The DDS File Format Lives and DDS Programmer's Guide.

Windows 8.x and Windows 10 include a built-in WIC codec which supports DDS files in DXTn (aka BC1-BC3) format. No other formats are supported.

To aid in debugging, here is a simple console program for dumping out the content of a DDS header in a human-readable form. It requires the dds.h header in the DirectXTex library to build.

EXR (OpenEXR)

The EXR file format is a high dynamic-range (HDR) image file format developed by Industrial Light & Magic for use in computer imaging applications. This format is implemented by the OpenEXR library.

Use of EXR requires the OpenEXR library and additional code. See Adding OpenEXR for more details.

Kainz, Bogart, and Hess. "Chapter 26. The OpenEXR Image File Format", GPU Gems, Addison-Wesley, 2004 link

GIF (Graphics Interchange Format)

The GIF file format is a Web meme standard that can contain multiple 'frames' of animation, but is otherwise limited to 256 colors. It is supported by a built-in WIC codec. See Wikipedia for more details and history.

HD Photo (Windows Media Photo)

The WDP file format (aka JPEG-XR) is a High-Dynamic Range (HDR) image file format. It is supported by a built-in WIC codec. See the HD Photo Specification and Wikipedia for more details.

Note that the Xbox One XDK version of WIC does not include the HD Photo codec.

HDR (Radiance RGBE)

The HDR file format is a High-Dynamic Range (HDR) image file format, and is commonly used as a source for textures. See Wikipedia for more details.

Greg Ward, "Real Pixels", Graphics Gems II, James Arvo (editor), Academic Press, 1991, ISBN: 0120644819, p. 80-83 (code)

To aid in debugging, here is a simple console program for dumping out the content of a HDR header.

JPEG (Joint Photographic Experts Group)

The JPG or JPEG file format is a lossy compressed image file format commonly used for photos. See Independent JPEG Group and Wikipedia for more details.

For support for this file format on Windows Subsystem for Linux, see Using-JPEG-PNG-OSS.

PNG (Portable Network Graphics)

The PNG file format is a commonly used lossless compressed image file format, which has largely taken over for GIF in use for general web graphics. See libpng and Wikipedia for more details and history.

For support for this file format on Windows Subsystem for Linux, see Using-JPEG-PNG-OSS.

PPM/PFM (Portable PixMap/Portable Float Map)

The PPM file is an 80s era extremely simple file format that supports RGB values in ASCII or binary format. PFM is an extension of this format for floating-point RGB values. This format does not support compression or alpha channels, and it's primary utility is for loading some academic-provided image data.

These formats are not generally useful enough to be put into the DirectXTex library, but texconv supports them for interop with these academic repositories.

Legacy D3DX9 supports reading PPM, reading PFM, and writing PFM files. The PBM/PGM (BitMap / GreyMap) formats were not supported by legacy D3DX9.

See PPM / PGM / PBM image files and Unofficial PBM format for HDR images, PFM (Portable Float Map)

The original proposal for PFM states there are no # comment lines like in ppm. That said some tools like to add comments unless you explicitly tell them to not add them. D3DX9 fails to load a pfm with header comments.

TIFF (Tagged Image File Format)

The TIF or TIFF file format is kind of meta-container that is often used for image files used in various compressed formats, as well as other application. The image uses of this file format are supported by a built-in WIC codec. See Wikipedia for more details.

TGA (Truevision Graphics Adapter)

The TGA file format is one of the earliest and simplest file formats for 24-bits-per-pixel images, and is commonly used as a source file for textures. See Wikipedia, this text file, and the Version 2.0 specification for more details.

To aid in debugging, here is a simple console program for dumping out the content of a TGA header in a human-readable form.

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 - v18
  • GCC 10.5, 11.4, 12.3
  • MinGW 12.2, 13.2
  • CMake 3.20

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