Subject: bug#8402: 24.0.50; Hex colors are not rendered correctly on OS X (Cocoa)

From: Alan Third <[email-masked]>
Date: Sat, 23 Apr 2022 23:22:12 +0100

On Sat, Apr 23, 2022 at 05:33:35PM -0400, Howard Melman wrote:
> Lars Ingebrigtsen <[email-masked]> writes:
> 
> > Steve Purcell <[email-masked]> writes:
> >
> >> If I set face colors using hex values, those colors are not displayed
> >> correctly.
> >>
> >> For example, 'M-x set-face-background RET default RET #fdf6e3 RET'
> >> results in a frame background color which, when sampled using Apple's
> >> "Digital Color Meter" utility, has hex value #fff8e8.
> >
> > (I'm going through old bug reports that unfortunately weren't resolved
> > at the time.)
> >
> > There was a patch suggested to alter ns_get_color, but I see that the
> > function has changed greatly since this was reported ten years ago.
> >
> > Is this still an issue with recent Emacs versions?
> 
> When I try it with emacs 28 on macOS 11.6.5 I get the
> background color 0xFCF6E5.  So it seems quite close.

I think all this is a result of macOS's heavy use of colourspaces,
specifically conversion between "generic" and "SRGB" colourspaces.

But to be perfectly frank, colour on macOS confuses me so much so I
could be talking nonsense. If anyone does want to mess with this bear
in mind that if you mess it up it results in HUGE performance
penalties as every drawing action then has to run through colour
conversion routines.
-- 
Alan Third