Default Handling of sRGB JPG On Load

Jun 7, 2013 at 6:19 PM
Hi,

I'm loading an sRGB-encoded JPG thusly:
hr = LoadFromWICFile( <filename>, WIC_FLAGS_NONE, &md, scratch );

Given the JPG encoding, I would expect the resulting md.format to be DXGI_FORMAT_R8G8B8A8_UNORM_SRGB - but instead it is just DXGI_FORMAT_R8G8B8A8_UNORM.

Am I missing something?

Cheers,

Dave
Coordinator
Jun 7, 2013 at 6:33 PM
There are not specific WIC pixel format GUIDs that communicate explicitly the colorspace of the format (with the exception of the CMYK formats and GUID_WICPixelFormat32bppRGBA1010102XR). The general assumption in WIC is that UNORM formats are sRGB and that Fixed-point/float formats are linear RGB, but that's not explicitly indicated by the API.

The DirectXTex library therefore maps to 'generic' DXGI formats from WIC formats (see the g_WICFormats table in DirectXTexUtil.cpp) assuming they are device dependent colorspace. The DXGI_FORMAT_*_UNORM_SRGB formats are explicitly used by the .DDS file format, so loading that file will return this.

This is why we have the TEX_FILTER_SRGB_IN flag which indicates 'treat the input as if it were explicitly sRGB', which is exposed by the 'texconv' command-line arguments '-srgb'.

Now, in the case of JPEG it also by default assumes device color space. There is a metadata tag that would explicitly indicate sRGB colorspace, which I could find via the WIC metadata APIs for those formats that directly map to a DXGI_FORMAT_*_SRGB format. I don't currently use this information, but I could.

Can you attach your JPG to the new work item to give me something to try?
Coordinator
Jun 7, 2013 at 6:35 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jun 15, 2013 at 8:17 PM
This has been fixed for the June 2013 release
Jun 16, 2013 at 1:41 AM
Awesome, thanks!