1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 12:00:06 +00:00

Added IsBGR utility function

This commit is contained in:
Chuck Walbourn 2022-05-07 15:10:55 -07:00
parent 55a7bb03c4
commit 178753de4a
4 changed files with 28 additions and 2 deletions

View File

@ -63,6 +63,7 @@ namespace DirectX
bool __cdecl IsPalettized(_In_ DXGI_FORMAT fmt) noexcept;
bool __cdecl IsDepthStencil(_In_ DXGI_FORMAT fmt) noexcept;
bool __cdecl IsSRGB(_In_ DXGI_FORMAT fmt) noexcept;
bool __cdecl IsBGR(_In_ DXGI_FORMAT fmt) noexcept;
bool __cdecl IsTypeless(_In_ DXGI_FORMAT fmt, _In_ bool partialTypeless = true) noexcept;
bool __cdecl HasAlpha(_In_ DXGI_FORMAT fmt) noexcept;

View File

@ -116,6 +116,27 @@ inline bool __cdecl IsSRGB(DXGI_FORMAT fmt) noexcept
}
}
_Use_decl_annotations_
inline bool __cdecl IsBGR(DXGI_FORMAT fmt) noexcept
{
switch (fmt)
{
case DXGI_FORMAT_B5G6R5_UNORM:
case DXGI_FORMAT_B5G5R5A1_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
case DXGI_FORMAT_B4G4R4A4_UNORM:
return true;
default:
return false;
}
}
//=====================================================================================
// Image I/O

View File

@ -1443,7 +1443,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
else if (_wcsicmp(ext, L".tga") == 0)
{
hr = LoadFromTGAFile(pConv->szSrc, TGA_FLAGS_NONE, &info, *image);
TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
hr = LoadFromTGAFile(pConv->szSrc, tgaFlags, &info, *image);
if (FAILED(hr))
{
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));

View File

@ -2051,7 +2051,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
}
else if (_wcsicmp(ext, L".tga") == 0)
{
hr = LoadFromTGAFile(pConv->szSrc, TGA_FLAGS_NONE, &info, *image);
TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE;
hr = LoadFromTGAFile(pConv->szSrc, tgaFlags, &info, *image);
if (FAILED(hr))
{
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));