Search code examples
c#c++xamlwin-universal-appdds-format

Load and display DDS (DXT1) file in UWP app


I want to load a couple of directdraw surface files specifically DXT1 and display them in my very simple UWP (C# mainly) application.

I have read of DirectXTex but I have no idea if this is the simplest way and if so, how to use it in an UWP application.


Solution

  • In Windows 8.1 and Windows 10, the Windows Imaging Component has a built-in codec for loading DDS files that use BC1/DXT1 compression. The simplest way to use WIC from a C# UWP is to use Win2D. Keep in mind WIC is going to return an uncompressed version of the image, which if that's what you want then you are good-to-go.

    Note that the built-in DDS codec only supports DXT1-DXT5/BC1-BC3 2D image files. It won't load other forms of DDS files. A quick way to check is to look in File Explorer. If the DDS shows up with a thumbnail, it's supported.

    It's not clear from your question what it is you are going to do with the loaded data. If you want to use Direct3D from C#, then you should look at something like SharpDX or SlimDX. If you are using Direct2D, Win2D is the way to go.

    For when to use DirectXTex vs. DDSTextureLoader for loading DDS files, see this blog post. In short: DirectXTex is for tools that need to handle all the various format conversions particularly legacy DDS file formats; DDSTextureLoader in DirectX Tool Kit is intended for 'runtime' use where you can ensure you are loading a DDS file that is already in a supported DXGI format.