mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-09 22:26:13 +01:00
SaveToWIC* functions updated with optional setCustomProps parameter for setting custom encoding options
This commit is contained in:
@@ -839,7 +839,8 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_ REFGUID guidContainerFormat,
|
||||
_In_z_ LPCWSTR fileName,
|
||||
_In_opt_ const GUID* targetFormat )
|
||||
_In_opt_ const GUID* targetFormat,
|
||||
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps )
|
||||
{
|
||||
if ( !fileName )
|
||||
return E_INVALIDARG;
|
||||
@@ -927,21 +928,21 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 )
|
||||
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 && g_WIC2 )
|
||||
{
|
||||
// Opt-in to the Windows 8 support for writing 32-bit Windows BMP files with an alpha channel if supported
|
||||
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
||||
PROPBAG2 option = { 0 };
|
||||
option.pstrName = L"EnableV5Header32bppBGRA";
|
||||
|
||||
VARIANT varValue;
|
||||
varValue.vt = VT_BOOL;
|
||||
varValue.boolVal = VARIANT_TRUE;
|
||||
hr = props->Write( 1, &option, &varValue );
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
// Fails on older versions of WIC, so we default to the null property bag
|
||||
props.Reset();
|
||||
}
|
||||
(void)props->Write( 1, &option, &varValue );
|
||||
}
|
||||
|
||||
if ( setCustomProps )
|
||||
{
|
||||
setCustomProps( props.Get() );
|
||||
}
|
||||
|
||||
hr = frame->Initialize( props.Get() );
|
||||
|
||||
@@ -25,11 +25,15 @@
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include <ocidl.h>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4005)
|
||||
#include <stdint.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
HRESULT SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
@@ -42,7 +46,8 @@ namespace DirectX
|
||||
_In_ ID3D11Resource* pSource,
|
||||
_In_ REFGUID guidContainerFormat,
|
||||
_In_z_ LPCWSTR fileName,
|
||||
_In_opt_ const GUID* targetFormat = nullptr );
|
||||
_In_opt_ const GUID* targetFormat = nullptr,
|
||||
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps = nullptr );
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user