Skip to content

Commit

Permalink
Added WIC_LOADER_SRGB_DEFAULT flag to WICTextureLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Jun 2, 2020
1 parent acb8938 commit bdad044
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Inc/WICTextureLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,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,
};

// Standard version
Expand Down
16 changes: 16 additions & 0 deletions Src/WICTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ namespace
{
sRGB = (value.uintVal == 45455);
}
else
{
sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0;
}
}
#if defined(_XBOX_ONE) && defined(_TITLE)
else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
Expand All @@ -475,19 +479,31 @@ namespace
{
sRGB = (value.uiVal == 1);
}
else
{
sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0;
}
}
else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0)
{
if (SUCCEEDED(metareader->GetMetadataByName(L"/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2)
{
sRGB = (value.uiVal == 1);
}
else
{
sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0;
}
}
#else
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;
}
#endif

(void)PropVariantClear(&value);
Expand Down

0 comments on commit bdad044

Please sign in to comment.