darktable windows insider program 11/2/25

I looked quickly to why is the color management broken on windows with multi monitor setup. (inspired by the wayland pr)

It seems to me that the culprit is:

HDC hdc = GetDC(NULL);
…
if(GetICMProfileW(hdc, &len, wpath))

The function GetDC(0) should return device context (DC) of whole virtual desktop which practically means the primary screen only as it’s where it starts with 0,0 coordinates. So it’s not usable for determining the current screen DC.

Sources:

The solution from microsoft suggested in this doc GetWindowDC function (winuser.h) - Win32 apps | Microsoft Learn is:

“To get the device context for other display monitors, use the EnumDisplayMonitors and CreateDC functions.”

This seems also how SDL devs fixed the issue:

hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
if (hdc) {
succeeded = GetICMProfileW(hdc, &fileNameSize, icmFileName);
...

Similar approach with CreateDCW like SDL used may be usable also here for darktable.

However what may complicate the situation is that some people reported that due to bug in windows11 this old win32 api function GetICMProfileW is not working reliably anymore (see link below). And now recommended way is to use WCS api instead.

That means WcsGetDefaultColorProfile function which don’t require DC anymore, but would require wcsapi.h and also probably with MonitorFromWindow function to find the monitor first.

However I won’t be investigating it any further since I don’t use windows nowadays.