SaveToWIC* functions updated with optional setCustomProps parameter for setting custom encoding options

This commit is contained in:
walbourn_cp
2013-06-27 11:05:15 -07:00
parent bb622bf4ec
commit 61a0a1a19c
4 changed files with 57 additions and 36 deletions

View File

@@ -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() );

View File

@@ -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
}