Windows gamma adjustments

When porting Redshift to Windows I ran into trouble when setting a color temperature lower than about 4500K. The problem is that Windows sets limitations on what kinds of gamma adjustments can be made, probably as a means of protecting the user against evil programs that invert the colors, blank the display, or play some other annoying trick with the gamma ramps. This kind of limitation is perhaps understandable, but the problem is the complete lack of documentation of this feature (SetDeviceGammaRamp on MSDN). A program that tries to set a gamma ramp that is not allowed will simply fail with a generic error leaving the programmer wondering what went wrong.

There are workarounds, but you will not find them anywhere unless you have the patience to work your way through assembly listings of Windows DLLs. So here they are, for your convenience; these two tricks will work at least on a Windows 7 machine:

  • Go to the registry database and create the key “GdiIcmGammaRange” (that’s a capital I in Icm as in Image Color Management) under “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ICM”. The type must be DWORD. The value determines the amount of adjustment that can be made, where 0 means no adjustments possible at all, and 256 means any adjustment is allowed. You’ll find a REG-file below that sets it to 256.
  • Run your program from the Local System account.

The registry key should be set as shown in this screen shot.

So if you want to run the experimental build of Redshift on Windows, you need to use one of the above methods if you want to use the same color temperatures as are available on the linux version.

Update: Here’s a REG-file that will set the appropriate key in the registry: RemoveGammaLimitation.reg. Save it with a “.reg” extension and double click to apply.

f.lux for Linux

I have been using f.lux for some time now and it is a really nice tool. It adjusts the color temperature of the screen at night to a more reddish tone which greatly reduces the strain on the eyes. It takes a while to get used to the red tint but now there is no going back.

When I learned that there is a version for linux (xflux) I had to get that for my Ubuntu laptop. I was quite disappointed, however, when I discovered that not only does it not feature a sleek GUI like the windows version, it also simply does not work at all on my laptop. f.lux throws this message at me: “Sorry, we only support 24/32-bit displays right now” which must be a bug because I am running in 24-bit mode with the open source radeon driver.

Other features that are present in the windows version seem to be missing as well in xflux, like setting the daytime temperature. Ultimately I decided to code my own tool to adjust the color temperature. The result is an open source program called Redshift.

Please post comments here.