From 2873a800d0f85b212ad443f37c080ecf7977f941 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Mon, 1 Jun 2020 19:00:09 -0700 Subject: [PATCH] Added WIC_LOADER_SRGB_DEFAULT flag to WICTextureLoader --- DDSTextureLoader/DDSTextureLoader12.h | 6 +++--- WICTextureLoader/WICTextureLoader11.cpp | 8 ++++++++ WICTextureLoader/WICTextureLoader11.h | 3 ++- WICTextureLoader/WICTextureLoader12.cpp | 8 ++++++++ WICTextureLoader/WICTextureLoader12.h | 7 ++++--- WICTextureLoader/WICTextureLoader9.h | 4 ++-- 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/DDSTextureLoader/DDSTextureLoader12.h b/DDSTextureLoader/DDSTextureLoader12.h index 6dbc6ab..0bddae8 100644 --- a/DDSTextureLoader/DDSTextureLoader12.h +++ b/DDSTextureLoader/DDSTextureLoader12.h @@ -39,9 +39,9 @@ namespace DirectX enum DDS_LOADER_FLAGS { - DDS_LOADER_DEFAULT = 0, - DDS_LOADER_FORCE_SRGB = 0x1, - DDS_LOADER_MIP_RESERVE = 0x8, + DDS_LOADER_DEFAULT = 0, + DDS_LOADER_FORCE_SRGB = 0x1, + DDS_LOADER_MIP_RESERVE = 0x8, }; // Standard version diff --git a/WICTextureLoader/WICTextureLoader11.cpp b/WICTextureLoader/WICTextureLoader11.cpp index 6996439..a0f3402 100644 --- a/WICTextureLoader/WICTextureLoader11.cpp +++ b/WICTextureLoader/WICTextureLoader11.cpp @@ -534,11 +534,19 @@ namespace { sRGB = (value.uintVal == 45455); } + else + { + sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; + } } else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2) { sRGB = (value.uiVal == 1); } + else + { + sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; + } (void)PropVariantClear(&value); diff --git a/WICTextureLoader/WICTextureLoader11.h b/WICTextureLoader/WICTextureLoader11.h index 802cc7e..0ede2ea 100644 --- a/WICTextureLoader/WICTextureLoader11.h +++ b/WICTextureLoader/WICTextureLoader11.h @@ -36,9 +36,10 @@ namespace DirectX WIC_LOADER_DEFAULT = 0, WIC_LOADER_FORCE_SRGB = 0x1, WIC_LOADER_IGNORE_SRGB = 0x2, - WIC_LOADER_FORCE_RGBA32 = 0x10, + WIC_LOADER_SRGB_DEFAULT = 0x4, WIC_LOADER_FIT_POW2 = 0x20, WIC_LOADER_MAKE_SQUARE = 0x40, + WIC_LOADER_FORCE_RGBA32 = 0x80, }; #endif diff --git a/WICTextureLoader/WICTextureLoader12.cpp b/WICTextureLoader/WICTextureLoader12.cpp index 894898e..9970479 100644 --- a/WICTextureLoader/WICTextureLoader12.cpp +++ b/WICTextureLoader/WICTextureLoader12.cpp @@ -445,11 +445,19 @@ namespace { sRGB = (value.uintVal == 45455); } + else + { + sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; + } } else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2) { sRGB = (value.uiVal == 1); } + else + { + sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; + } (void)PropVariantClear(&value); diff --git a/WICTextureLoader/WICTextureLoader12.h b/WICTextureLoader/WICTextureLoader12.h index 780ea27..d1fa2bb 100644 --- a/WICTextureLoader/WICTextureLoader12.h +++ b/WICTextureLoader/WICTextureLoader12.h @@ -35,11 +35,12 @@ namespace DirectX WIC_LOADER_DEFAULT = 0, WIC_LOADER_FORCE_SRGB = 0x1, WIC_LOADER_IGNORE_SRGB = 0x2, - WIC_LOADER_MIP_AUTOGEN = 0x4, - WIC_LOADER_MIP_RESERVE = 0x8, - WIC_LOADER_FORCE_RGBA32 = 0x10, + WIC_LOADER_SRGB_DEFAULT = 0x4, + WIC_LOADER_MIP_AUTOGEN = 0x8, + WIC_LOADER_MIP_RESERVE = 0x10, WIC_LOADER_FIT_POW2 = 0x20, WIC_LOADER_MAKE_SQUARE = 0x40, + WIC_LOADER_FORCE_RGBA32 = 0x80, }; #endif diff --git a/WICTextureLoader/WICTextureLoader9.h b/WICTextureLoader/WICTextureLoader9.h index 328fc58..c47bddf 100644 --- a/WICTextureLoader/WICTextureLoader9.h +++ b/WICTextureLoader/WICTextureLoader9.h @@ -33,10 +33,10 @@ namespace DirectX enum WIC_LOADER_FLAGS : uint32_t { WIC_LOADER_DEFAULT = 0, - WIC_LOADER_MIP_AUTOGEN = 0x4, - WIC_LOADER_FORCE_RGBA32 = 0x10, + WIC_LOADER_MIP_AUTOGEN = 0x8, WIC_LOADER_FIT_POW2 = 0x20, WIC_LOADER_MAKE_SQUARE = 0x40, + WIC_LOADER_FORCE_RGBA32 = 0x80, }; #endif