-
Notifications
You must be signed in to change notification settings - Fork 452
Using JPEG PNG OSS
DirectXTex |
---|
The DirectXTex library makes use of the Windows Imaging Component (WIC) which includes a number of built-in codecs for BMP, JPEG, PNG, etc. On Windows Subsystem for Linux, however, WIC is not present so only the DDS, HDR, and TGA file formats are supported by the library.
Using CMake there is an option to opt-in to using the Open Source libjpeg (ENABLE_LIBJPEG_SUPPORT
) and/or libpng (ENABLE_LIBPNG_SUPPORT
) libraries to provide support for these file formats on Windows Subsystem for Linux.
The CMake option to use these libraries is also supported on Windows, but this is not recommended for both security servicing and code size reasons. They are supported on Windows for testing purposes.
The files Auxiliary/DirectXTexJPEG.h
and DirectXTexJPEG.cpp
implement the following wrapper functions for libjpeg (ijg-libjpeg or libjpeg-turbo).
With the vcpkg C++ Package Manager, you can opt in to the png
feature to include this functionality for Linux:
vcpkg install directxtex[png]
The libjpeg-turbo library is licensed under BSD-3-Clause, while ijg-libjpeg has a custom license.
HRESULT GetMetadataFromJPEGFile(const wchar_t* szFile, TexMetadata& metadata);
HRESULT LoadFromJPEGFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image);
HRESULT SaveToJPEGFile(const Image& image, const wchar_t* szFile);
The files Auxiliary/DirectXTexPNG.h
and DirectXTexPNG.cpp
implement the following wrapper functions for libpng.
With the vcpkg C++ Package Manager, you can opt in to the jpeg
feature to include this functionality for Linux:
vcpkg install directxtex[jpeg]
The libpng library is licensed under a custom license known as the PNG Reference Library License.
HRESULT GetMetadataFromPNGFile(const wchar_t* szFile, TexMetadata& metadata);
HRESULT LoadFromPNGFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image);
HRESULT SaveToPNGFile(const Image& image, const wchar_t* szFile);
Thanks to Park DongHa for their contribution of these functions to the library.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- 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
DirectX Tool Kit for DirectX 11