mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
Added WIC_FLAGS_DEFAULT_SRGB flag (#178)
This commit is contained in:
parent
07c0aaa045
commit
21f7e28b80
@ -202,6 +202,9 @@ namespace DirectX
|
|||||||
WIC_FLAGS_FORCE_LINEAR = 0x80,
|
WIC_FLAGS_FORCE_LINEAR = 0x80,
|
||||||
// Writes linear gamma metadata into the file reguardless of format
|
// Writes linear gamma metadata into the file reguardless of format
|
||||||
|
|
||||||
|
WIC_FLAGS_DEFAULT_SRGB = 0x100,
|
||||||
|
// If no colorspace is specified, assume sRGB
|
||||||
|
|
||||||
WIC_FLAGS_DITHER = 0x10000,
|
WIC_FLAGS_DITHER = 0x10000,
|
||||||
// Use ordered 4x4 dithering for any required conversions
|
// Use ordered 4x4 dithering for any required conversions
|
||||||
|
|
||||||
|
@ -318,33 +318,53 @@ namespace
|
|||||||
PROPVARIANT value;
|
PROPVARIANT value;
|
||||||
PropVariantInit(&value);
|
PropVariantInit(&value);
|
||||||
|
|
||||||
|
// Check for colorspace chunks
|
||||||
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
// Check for sRGB chunk
|
|
||||||
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
}
|
}
|
||||||
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4)
|
||||||
|
{
|
||||||
|
sRGB = (value.uintVal == 45455);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
|
else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(metareader->GetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2 && value.uiVal == 1)
|
if (SUCCEEDED(metareader->GetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = (value.uiVal == 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0)
|
else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(metareader->GetMetadataByName(L"/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2 && value.uiVal == 1)
|
if (SUCCEEDED(metareader->GetMetadataByName(L"/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = (value.uiVal == 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2 && value.uiVal == 1)
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = (value.uiVal == 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -518,23 +518,26 @@ namespace
|
|||||||
GUID containerFormat;
|
GUID containerFormat;
|
||||||
if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat)))
|
if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat)))
|
||||||
{
|
{
|
||||||
// Check for sRGB colorspace metadata
|
|
||||||
bool sRGB = false;
|
bool sRGB = false;
|
||||||
|
|
||||||
PROPVARIANT value;
|
PROPVARIANT value;
|
||||||
PropVariantInit(&value);
|
PropVariantInit(&value);
|
||||||
|
|
||||||
|
// Check for colorspace chunks
|
||||||
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
// Check for sRGB chunk
|
|
||||||
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
}
|
}
|
||||||
}
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4)
|
||||||
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2 && value.uiVal == 1)
|
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = (value.uintVal == 45455);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2)
|
||||||
|
{
|
||||||
|
sRGB = (value.uiVal == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)PropVariantClear(&value);
|
(void)PropVariantClear(&value);
|
||||||
|
@ -429,23 +429,26 @@ namespace
|
|||||||
GUID containerFormat;
|
GUID containerFormat;
|
||||||
if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat)))
|
if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat)))
|
||||||
{
|
{
|
||||||
// Check for sRGB colorspace metadata
|
|
||||||
bool sRGB = false;
|
bool sRGB = false;
|
||||||
|
|
||||||
PROPVARIANT value;
|
PROPVARIANT value;
|
||||||
PropVariantInit(&value);
|
PropVariantInit(&value);
|
||||||
|
|
||||||
|
// Check for colorspace chunks
|
||||||
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0)
|
||||||
{
|
{
|
||||||
// Check for sRGB chunk
|
|
||||||
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1)
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = true;
|
||||||
}
|
}
|
||||||
}
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4)
|
||||||
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2 && value.uiVal == 1)
|
|
||||||
{
|
{
|
||||||
sRGB = true;
|
sRGB = (value.uintVal == 45455);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2)
|
||||||
|
{
|
||||||
|
sRGB = (value.uiVal == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)PropVariantClear(&value);
|
(void)PropVariantClear(&value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user