Added error check to SaveWIC functions if requested optional targetFormat is not supported by the WIC codec
This commit is contained in:
parent
6323465f1f
commit
24ead31a39
@ -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
|
||||
|
@ -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) )
|
||||
|
Loading…
Reference in New Issue
Block a user