Tk Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
Ticket UUID: 3501372
Title: Washed out colors on Mac OS X display
Type: Bug Version: obsolete: 8.5.10
Submitter: parasytic Created on: 2012-03-10 22:39:51
Subsystem: 29. Colormaps and Visuals Assigned To: kevin_walzer
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2015-01-31 23:14:17
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2015-01-31 23:14:17
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 2.7.2, and ActiveTcl

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.
User Comments: kevin_walzer added on 2015-01-31 23:14:17:
Fix last year should address this, hence I am closing it. The bug was the result of changes in Apple's NSColor API.

kevin_walzer added on 2014-10-31 00:06:53:
Can you confirm the recent release of Tcl/Tk addresses this? If not I will have to investigate further.

kevin_walzer added on 2014-10-29 13:54:37:
I can't download the attached PNG to see, but a recent commit to address internal color rendering issues on OS X likely fixed this, so I am closing the bug.

parasytic added on 2012-03-11 06:15:46:
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.

parasytic added on 2012-03-11 05:40:52:

File Added - 437960:

parasytic added on 2012-03-11 05:39:52:

File Added - 437959: grays.png