While building a Tk app in Python on Mac OS X 10.7.3, I noticed the colors appear consistently "washed out" as if there is some sort of bad gamma correction going on under the hood. As a test, I write a very simple app that draws 1-pixel-high rectangles to a canvas with varying levels of intensity on each of the RGB channels, creating a black-to-white gradient.
Second, I created a black-to-white gradient in GIMP to use as a baseline. When placed side-by-side, it's pretty clear that Tk is adjusting colors incorrectly.
I've tried the same test on Linux, and it appears to work correctly, displaying the same exact gradient as generated by GIMP. I have also tried updating ActiveTcl and Python on OS X, but the problem persists. I'm now using python.org Python 2.7.2, and ActiveTcl 8.5.11.1.
Attached is a PNG that illustrated the difference between the Tk gradient and the GIMP gradient, as well as the Python source I used to generate the Tk gradient.
Tk gradient vs GIMP gradient
Python source that generated the left side of grays.png
Some more info:
1. Displaying the GIMP gradient as a GIF in a Tk window shows the same "washed out" effect, where dark colors are too bright.
2. Using the pixel API to put and get back pixel colors in a photo always returns the expected RGB values. Whats displayed on screen is always unexpected (and verified with a screenshot)
3. The adjustment is non-linear, but the gamma correction algorithms I'm familiar with do not correctly counteract what's displayed. In the end, I decided to use the screenshot from the Tk gradient to build a LUT that can workaround the bug. It's not entirely accurate (the round-trip causes artifacts in the RGB intensities) but it's good enough for my project.
What I'm actually working on is a very simple way to theme my GUI, and in developing it, I'm trying to match a theme that comes with Sublime Text 2. You can imagine my surprise when my dark gray background was 4% brighter than in Sublime Text 2. (Expected #211E1E, got #2C2828) Definitely off enough to see the difference by eye.