Added error check to SaveWIC functions if requested optional targetFormat is not supported by the WIC codec

This commit is contained in:
walbourn_cp 2013-06-01 10:55:18 -07:00
parent 6323465f1f
commit 24ead31a39
2 changed files with 12 additions and 0 deletions

View File

@ -421,6 +421,12 @@ static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWI
if ( FAILED(hr) )
return hr;
if ( targetFormat && memcmp( targetFormat, &targetGuid, sizeof(WICPixelFormatGUID) ) != 0 )
{
// Requested output pixel format is not supported by the WIC codec
return E_FAIL;
}
if ( memcmp( &targetGuid, &pfGuid, sizeof(WICPixelFormatGUID) ) != 0 )
{
// Conversion required to write

View File

@ -1031,6 +1031,12 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
if ( FAILED(hr) )
return hr;
if ( targetFormat && memcmp( targetFormat, &targetGuid, sizeof(WICPixelFormatGUID) ) != 0 )
{
// Requested output pixel format is not supported by the WIC codec
return E_FAIL;
}
D3D11_MAPPED_SUBRESOURCE mapped;
hr = pContext->Map( pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped );
if ( FAILED(hr) )