在 UWP 应用程序中加载和显示 DDS (DXT1) 文件

Load and display DDS (DXT1) file in UWP app

我想加载几个 directdraw 表面文件,特别是 DXT1,并在我非常简单的 UWP(主要是 C#)应用程序中显示它们。

我读过 DirectXTex,但我不知道这是否是最简单的方法,如果是,如何在 UWP 应用程序中使用它。

在Windows8.1和Windows10中,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。请记住,WIC 将 return 图像的未压缩版本,如果这是您想要的,那么您就可以开始了。

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.

从你的问题中不清楚你将如何处理加载的数据。如果你想在 C# 中使用 Direct3D,那么你应该看看像 SharpDX or SlimDX 这样的东西。如果您使用的是 Direct2D,Win2D 是最佳选择。

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.

Win2D 可以直接从 BC 压缩像素格式加载和绘制:http://microsoft.github.io/Win2D/html/BlockCompression.htm