More Firefox color woe
Mar. 7th, 2007 01:15 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I complained a while ago about Firefox's broken color management on Macs. It turns out it's even more broken than that, and not only on Macs.
My home page has a gray background, set to 808080 hex in CSS. Embedded in it are some PNG images, again with a background color of 808080. So they should blend seamlessly into one another, right (whatever properties the browser thinks the monitor has, supposing it has an opinion at all)?
Display that page in Firefox 2.0 on Linux and here's (zoomed in) what you get:
Picking over that capture in the Gimp reveals that:
- The CSS-configured background is actually rendered as a solid 848284
- The background gray in the image is actually rendered as a randomly dithered pattern composed of 847d84 and 7b827b - at this magnification it looks visibly pink and green to my eyes though it's just a (visibly) different shade of gray without magnification.
(I initially spotted this on a Mac last night but assumed it was the same problem as before, perhaps compounded by using different interfaces for drawing background and images, but if it happens on Linux then too then it must be something fundamental to Firefox's treatment of color, probably far away from where you'd put color management support if the program actually had any).
(no subject)
Date: 2007-03-07 01:50 pm (UTC)A 16-bit display, not 15? Well, no wonder it can't do pure greys sensibly then. That would certainly seem like a plausible cause to me. And it doesn't seem too surprising to me, either, that the CSS renderer and the PNG renderer disagree on the best way to approximate a pure grey with the available colours: the PNG renderer is already going to be prepared to dither where necessary, whereas the CSS renderer would have to go to some effort to include dithering code so it will just approximate to the nearest solid colour.
that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 02:04 pm (UTC)Re: that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 02:15 pm (UTC)The other alternative is to have the dithering done universally, so that the PNG renderer outputs 24-bit data all the time and some top-level piece of code deals in a uniform way with converting it to the available colour depth. That doesn't strike me as a nice answer either, because even on a 16-bit display it doesn't seem obviously right to dither the entire window without better cause than that.
Having mentioned alpha blending ... it suddenly occurs to me, actually, to ask why you're trying to match up those backgrounds at all. PNG has an alpha channel, so why haven't you just set the parts of the image which want to be the same colour as the surrounding page to transparent? That might perfectly well actually work better.
Re: that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 02:39 pm (UTC)Re: that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 07:35 pm (UTC)What it does is attach a proprietary filter, via CSS2 DOM events, to PNGs in IE only; this changes the particular renderer used for them to one which supports alpha channels. Grotesque, innit? :)
Re: that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 02:45 pm (UTC)The good cause for following the 'other alternative' is precisely the need to match up images and backgrounds. Like I say, this isn't some obscure edge case I'm trying to use here, it's something pretty widespread on the web.
Whether the globally used mechanism is dithering or just picking the nearest available color is another question, but it should certainly be the same mechanism for different sources of color.
Firefox seems to have no compunction about using visually bad (but computationally cheap) methods of scaling images, so it's not like cheap-and-cheerful color approximation would downgrade something that was otherwise a good graphical display tool.
(I can't remember why I ended up with a 16-bit display on this machine; I'll see what goes wrong with 24 bits, or whether it likes 15 bits, at some point. But having a workaround doesn't mean that the implementation is OK.)
(no subject)
Date: 2007-03-07 02:49 pm (UTC)Re: that the CSS renderer and the PNG renderer disagree
Date: 2007-03-07 03:01 pm (UTC)The PNG renderer appears to be attempting to maintain the luminance for each pixel, and maintain the colour averaged over a set of pixels. That's a pretty smart thing to do given the lower spatial frequency of our colour perception, but obviously isn't going to match the CSS.
I think an alpha channel is the way to go here. IE will almost certainly ignore it a show the grey, while Firefox and co will use it to let the background show through properly.