mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
permissive- code cleanup
This commit is contained in:
parent
b47a7d13d9
commit
8fcd276eba
@ -367,7 +367,7 @@ namespace DirectX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LDRColorA LDRColorA::operator = (_In_ const HDRColorA& c)
|
LDRColorA operator = (_In_ const HDRColorA& c)
|
||||||
{
|
{
|
||||||
LDRColorA ret;
|
LDRColorA ret;
|
||||||
HDRColorA tmp(c);
|
HDRColorA tmp(c);
|
||||||
|
@ -574,7 +574,7 @@ namespace
|
|||||||
bool sRGB = IsSRGB(format);
|
bool sRGB = IsSRGB(format);
|
||||||
|
|
||||||
value.vt = VT_LPSTR;
|
value.vt = VT_LPSTR;
|
||||||
value.pszVal = "DirectXTex";
|
value.pszVal = const_cast<char*>("DirectXTex");
|
||||||
|
|
||||||
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
@ -781,7 +781,7 @@ namespace
|
|||||||
{
|
{
|
||||||
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
||||||
PROPBAG2 option = { 0 };
|
PROPBAG2 option = { 0 };
|
||||||
option.pstrName = L"EnableV5Header32bppBGRA";
|
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
|
||||||
|
|
||||||
VARIANT varValue;
|
VARIANT varValue;
|
||||||
varValue.vt = VT_BOOL;
|
varValue.vt = VT_BOOL;
|
||||||
|
@ -211,7 +211,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (m_handle)
|
if (m_handle)
|
||||||
{
|
{
|
||||||
FILE_DISPOSITION_INFO info = {0};
|
FILE_DISPOSITION_INFO info = {};
|
||||||
info.DeleteFile = TRUE;
|
info.DeleteFile = TRUE;
|
||||||
(void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
|
(void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
|
||||||
}
|
}
|
||||||
@ -602,8 +602,8 @@ namespace
|
|||||||
HRESULT CaptureTexture(
|
HRESULT CaptureTexture(
|
||||||
_In_ ID3D11DeviceContext* pContext,
|
_In_ ID3D11DeviceContext* pContext,
|
||||||
_In_ ID3D11Resource* pSource,
|
_In_ ID3D11Resource* pSource,
|
||||||
_Inout_ D3D11_TEXTURE2D_DESC& desc,
|
D3D11_TEXTURE2D_DESC& desc,
|
||||||
_Inout_ ComPtr<ID3D11Texture2D>& pStaging )
|
ComPtr<ID3D11Texture2D>& pStaging )
|
||||||
{
|
{
|
||||||
if ( !pContext || !pSource )
|
if ( !pContext || !pSource )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
@ -615,7 +615,7 @@ namespace
|
|||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
ComPtr<ID3D11Texture2D> pTexture;
|
ComPtr<ID3D11Texture2D> pTexture;
|
||||||
HRESULT hr = pSource->QueryInterface( IID_PPV_ARGS( pTexture.GetAddressOf() ) );
|
HRESULT hr = pSource->QueryInterface(IID_PPV_ARGS(pTexture.GetAddressOf()));
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ namespace
|
|||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||||
desc.Usage = D3D11_USAGE_STAGING;
|
desc.Usage = D3D11_USAGE_STAGING;
|
||||||
|
|
||||||
hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() );
|
hr = d3dDevice->CreateTexture2D(&desc, 0, pStaging.ReleaseAndGetAddressOf());
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -684,7 +684,7 @@ namespace
|
|||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||||
desc.Usage = D3D11_USAGE_STAGING;
|
desc.Usage = D3D11_USAGE_STAGING;
|
||||||
|
|
||||||
hr = d3dDevice->CreateTexture2D( &desc, 0, pStaging.GetAddressOf() );
|
hr = d3dDevice->CreateTexture2D(&desc, 0, pStaging.ReleaseAndGetAddressOf());
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
if ( !fileName )
|
if ( !fileName )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
D3D11_TEXTURE2D_DESC desc = {};
|
||||||
ComPtr<ID3D11Texture2D> pStaging;
|
ComPtr<ID3D11Texture2D> pStaging;
|
||||||
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
@ -891,13 +891,13 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
|
|
||||||
// Write header & pixels
|
// Write header & pixels
|
||||||
DWORD bytesWritten;
|
DWORD bytesWritten;
|
||||||
if ( !WriteFile( hFile.get(), fileHeader, static_cast<DWORD>( headerSize ), &bytesWritten, 0 ) )
|
if ( !WriteFile( hFile.get(), fileHeader, static_cast<DWORD>( headerSize ), &bytesWritten, nullptr ) )
|
||||||
return HRESULT_FROM_WIN32( GetLastError() );
|
return HRESULT_FROM_WIN32( GetLastError() );
|
||||||
|
|
||||||
if ( bytesWritten != headerSize )
|
if ( bytesWritten != headerSize )
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if ( !WriteFile( hFile.get(), pixels.get(), static_cast<DWORD>( slicePitch ), &bytesWritten, 0 ) )
|
if ( !WriteFile( hFile.get(), pixels.get(), static_cast<DWORD>( slicePitch ), &bytesWritten, nullptr ) )
|
||||||
return HRESULT_FROM_WIN32( GetLastError() );
|
return HRESULT_FROM_WIN32( GetLastError() );
|
||||||
|
|
||||||
if ( bytesWritten != slicePitch )
|
if ( bytesWritten != slicePitch )
|
||||||
@ -919,7 +919,7 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
if ( !fileName )
|
if ( !fileName )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
D3D11_TEXTURE2D_DESC desc = {};
|
||||||
ComPtr<ID3D11Texture2D> pStaging;
|
ComPtr<ID3D11Texture2D> pStaging;
|
||||||
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
HRESULT hr = CaptureTexture( pContext, pSource, desc, pStaging );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
@ -974,7 +974,7 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||||
}
|
}
|
||||||
|
|
||||||
IWICImagingFactory* pWIC = _GetWIC();
|
auto pWIC = _GetWIC();
|
||||||
if ( !pWIC )
|
if ( !pWIC )
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
|
|
||||||
@ -1007,8 +1007,8 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 && g_WIC2 )
|
if ( targetFormat && memcmp( &guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID) ) == 0 && g_WIC2 )
|
||||||
{
|
{
|
||||||
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
||||||
PROPBAG2 option = { 0 };
|
PROPBAG2 option = {};
|
||||||
option.pstrName = L"EnableV5Header32bppBGRA";
|
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
|
||||||
|
|
||||||
VARIANT varValue;
|
VARIANT varValue;
|
||||||
varValue.vt = VT_BOOL;
|
varValue.vt = VT_BOOL;
|
||||||
@ -1094,7 +1094,7 @@ HRESULT DirectX::SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
|||||||
PropVariantInit( &value );
|
PropVariantInit( &value );
|
||||||
|
|
||||||
value.vt = VT_LPSTR;
|
value.vt = VT_LPSTR;
|
||||||
value.pszVal = "DirectXTK";
|
value.pszVal = const_cast<char*>("DirectXTK");
|
||||||
|
|
||||||
if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 )
|
if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -738,7 +738,7 @@ namespace
|
|||||||
&bufferDesc,
|
&bufferDesc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(pStaging.GetAddressOf()));
|
IID_PPV_ARGS(pStaging.ReleaseAndGetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -1113,7 +1113,7 @@ HRESULT DirectX::SaveWICTextureToFile( ID3D12CommandQueue* pCommandQ,
|
|||||||
{
|
{
|
||||||
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
|
||||||
PROPBAG2 option = {};
|
PROPBAG2 option = {};
|
||||||
option.pstrName = L"EnableV5Header32bppBGRA";
|
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
|
||||||
|
|
||||||
VARIANT varValue;
|
VARIANT varValue;
|
||||||
varValue.vt = VT_BOOL;
|
varValue.vt = VT_BOOL;
|
||||||
@ -1190,7 +1190,7 @@ HRESULT DirectX::SaveWICTextureToFile( ID3D12CommandQueue* pCommandQ,
|
|||||||
PropVariantInit( &value );
|
PropVariantInit( &value );
|
||||||
|
|
||||||
value.vt = VT_LPSTR;
|
value.vt = VT_LPSTR;
|
||||||
value.pszVal = "DirectXTK";
|
value.pszVal = const_cast<char*>("DirectXTK");
|
||||||
|
|
||||||
if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 )
|
if ( memcmp( &guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID) ) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -2334,7 +2334,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
{
|
{
|
||||||
PROPBAG2 options = {};
|
PROPBAG2 options = {};
|
||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
options.pstrName = L"ImageQuality";
|
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
|
||||||
varValues.vt = VT_R4;
|
varValues.vt = VT_R4;
|
||||||
varValues.fltVal = (wicLossless) ? 1.f : wicQuality;
|
varValues.fltVal = (wicLossless) ? 1.f : wicQuality;
|
||||||
(void)props->Write(1, &options, &varValues);
|
(void)props->Write(1, &options, &varValues);
|
||||||
@ -2347,13 +2347,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
if (wicLossless)
|
if (wicLossless)
|
||||||
{
|
{
|
||||||
options.pstrName = L"TiffCompressionMethod";
|
options.pstrName = const_cast<wchar_t*>(L"TiffCompressionMethod");
|
||||||
varValues.vt = VT_UI1;
|
varValues.vt = VT_UI1;
|
||||||
varValues.bVal = WICTiffCompressionNone;
|
varValues.bVal = WICTiffCompressionNone;
|
||||||
}
|
}
|
||||||
else if (wicQuality >= 0.f)
|
else if (wicQuality >= 0.f)
|
||||||
{
|
{
|
||||||
options.pstrName = L"CompressionQuality";
|
options.pstrName = const_cast<wchar_t*>(L"CompressionQuality");
|
||||||
varValues.vt = VT_R4;
|
varValues.vt = VT_R4;
|
||||||
varValues.fltVal = wicQuality;
|
varValues.fltVal = wicQuality;
|
||||||
}
|
}
|
||||||
@ -2369,13 +2369,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
VARIANT varValues = {};
|
VARIANT varValues = {};
|
||||||
if (wicLossless)
|
if (wicLossless)
|
||||||
{
|
{
|
||||||
options.pstrName = L"Lossless";
|
options.pstrName = const_cast<wchar_t*>(L"Lossless");
|
||||||
varValues.vt = VT_BOOL;
|
varValues.vt = VT_BOOL;
|
||||||
varValues.bVal = TRUE;
|
varValues.bVal = TRUE;
|
||||||
}
|
}
|
||||||
else if (wicQuality >= 0.f)
|
else if (wicQuality >= 0.f)
|
||||||
{
|
{
|
||||||
options.pstrName = L"ImageQuality";
|
options.pstrName = const_cast<wchar_t*>(L"ImageQuality");
|
||||||
varValues.vt = VT_R4;
|
varValues.vt = VT_R4;
|
||||||
varValues.fltVal = wicQuality;
|
varValues.fltVal = wicQuality;
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ HRESULT DirectX::CreateWICTextureFromFileEx(ID3D11Device* d3dDevice,
|
|||||||
{
|
{
|
||||||
if (texture != 0 || textureView != 0)
|
if (texture != 0 || textureView != 0)
|
||||||
{
|
{
|
||||||
CHAR strFileA[MAX_PATH];
|
char strFileA[MAX_PATH];
|
||||||
int result = WideCharToMultiByte(CP_ACP,
|
int result = WideCharToMultiByte(CP_ACP,
|
||||||
WC_NO_BEST_FIT_CHARS,
|
WC_NO_BEST_FIT_CHARS,
|
||||||
fileName,
|
fileName,
|
||||||
@ -900,7 +900,7 @@ HRESULT DirectX::CreateWICTextureFromFileEx(ID3D11Device* d3dDevice,
|
|||||||
);
|
);
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
{
|
{
|
||||||
const CHAR* pstrName = strrchr(strFileA, '\\');
|
const char* pstrName = strrchr(strFileA, '\\');
|
||||||
if (!pstrName)
|
if (!pstrName)
|
||||||
{
|
{
|
||||||
pstrName = strFileA;
|
pstrName = strFileA;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user