Tk Source Code

View Ticket
Login
Ticket UUID: 111de2edd2e67af350ffa564dbf65ab7a5fcf04c
Title: Tk colors on Mac: blue is not blue
Type: Bug Version: 8.6.7
Submitter: anonymous Created on: 2017-10-08 20:42:13
Subsystem: 41. Photo Images Assigned To: kevin_walzer
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2017-11-11 03:41:42
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2017-11-11 03:41:42
Description:
Please take a look at the attached screenshot:
I have a toplevel-window with blue (#0000FF) background, containing a small
label-widget holding a tk-photo.
The tk-photo is a 20x20 image filled with blue pixels #0000FF.
On Windows/Linux these tk-photo's colors are identical to the toplevel's background;
On Mac these blue pixels are different from the toplevels' pixels !

This difference between the rendering of widget's background and tk-photo pixels
is not only for blue pixels; it occurs for all the colours.

Tested with Tcl 8.6.6 and 8.6.7

On Mac, (tested with DigitalColorMeter)
the background's pixels are (0 0 255)
the label's image's pixels are (12 61 246) !! 

I also tried to load a PNG file made of #0000ff pixels, with the same (wrong) results.
Same wrong results with a GIF file.


I' don't know how to solve this paradox, nor even I know how to componsate this difference,
since, from the Tcl point of view, the background is blue and the tk-photo is the same blue, no difference 

Here is a small script for reproducing this case.

   # -- create an image 20x20 filled with blue pixels
  image create photo bluePhoto
  bluePhoto put #0000ff -to 0 0 20 20

   # -- create a label-widget holding the image
  label .blueLabel -image bluePhoto
  
  pack .blueLabel
   # -- change the background of its container
  . configure -background #0000ff
  
   # -  for a better visual perception of the contrast between the 
   # -   blue background and the blue label
   # -  remove all the label-widget's borders
  .blueLabel configure -borderwidth 0 -padx 0 -pady 0
User Comments: anonymous added on 2017-10-26 22:45:08:
ABU:  OK tested with tcltk 8.7a2  ( tcltk-kit built today from development-trunk with http://kitcreator.rkeene.org/kitcreator).

kevin_walzer added on 2017-10-12 12:47:54:
Check-in [be9900e3] fixes this issue. Please confirm.

bll added on 2017-10-11 23:14:45:
Another comparison shot using Tcl 8.6.7.

The original PNG: #0000ff

The color value is using gimp from the screenshot of the VNC view of the monitor.

If I use digital color meter with "display native values", I get the 
same color values as gimp.

Chrome: bottom left: #0005fd 
Preview: top right: #0005ff 
Safari: bottom right: #0005ff 
Tcl background: #0000ff    
Tcl Photo: #0034ff 
Tcl PNG: #0034ff        
Tcl GIF: #0034ff

anonymous added on 2017-10-11 21:40:55:
Hi Kevin, I appreciate your efforts,
and I'm not an expert of advanced color management, but maybe the right thing to do is different.
Let me explain: 
On MacOS we have the same color #0000FF renderend differently if painted as a tk-photo or as simple widget-background.
The fact that blue pixels from a photo are rendered by Tk as (12 61 246) (measured with DigitalColorMeter) could be disconcerting,
but maybe it's not wrong , at least from a MacOS point of view ! 
In fact if we open blue.png with MacOS Preview (or other image viewers) and pick the colors on the screen with DigitalColorMeter, we still get that disconcerting rgb value !.

Maybe what is wrong is the rendering of the widget's background. 
Currently Tk renders 'blue' on a widget's background  background as #0000ff (measured with DigitalColorMeter) but maybe it should be rendered as the 'other' blue.

I didn't tested your patch yet, but I fear that in that way pictures (png, jpg, ...) in a Tk window could look with strange colors (with respect to Preview or other image viewers ..)

As I said before, I was disconcerted for this strange color adjustment, but this is the MacOS way !

ABU

kevin_walzer added on 2017-10-11 12:00:45:
I have committed https://core.tcl.tk/tk/info/30ef75d2271bad9244bd779ede16a55a90ca0dd529723f4a46abf4f6fd6cdbbb, which partially fixes this issue by setting the Tk/Mac colorspace to sRGB. It reduces but does not completely eliminate the contrast visible in the colors as referenced in the demo.

bll added on 2017-10-09 19:02:15:
Now this is interesting:

The tclsh that ships with Mac OS X, 8.5.9, has both the photo, gif and background colors wrong (see attached, 8.5.9 doesn't support PNG, so the middle row does not apply).

So something got fixed between 8.5.9 and 8.6.7 for color display processing, but also needs fixing in image display.

bll added on 2017-10-09 18:49:21:
Same problem with GIF and PNG images.
See attached.

anonymous added on 2017-10-09 17:41:32:
Tested on MacOS Sierra 10.12.6

kevin_walzer added on 2017-10-08 23:36:51:
What version of macOS?

Attachments: