Background Colors

JQ Johnson jqj at darkwing.uoregon.edu
Tue Mar 12 16:31:58 EST 1996


kjustie at mgk.nslsilus.org (Kevin Justie) asks why his background colors
(that look fine on a Mac) appear dithered when viewed with Netscape on a
PC.  The answer is slightly complex.  Basically, the problem is that not
all colors an author might want are available; the display hardware is
typically capable of showing only 256 colors on the screen (not just in the
window) at a time, and the system reserves some colors, making the set of
colors Netscape has available less than 256. Netscape allocates a color
cube, normally 6x6x6 (216 colors in all), then if it needs to display a
color not in its color cube dithers the image to approximate it using
nearby colors in its color cube.  The bottom line is that the only colors
likely to be available in Netscape on a PC are those with 00, 33, 66, 99,
CC, or FF in each of the red, green, and blue fields of the color triplet
(#rrggbb).

Note that this set of 216 colors is a subset of the Mac 8-bit "system
colors", so using these colors is also good on a Mac.  I believe that on a
Mac Netscape normally uses the system color palette.

However, there is additional complexity.  Netscape can't always allocate a
6x6x6 color cube.  The user's PC hardware might not allow 256 colors, or
too many colors might be reserved for other purposes.  In that case, older
versions of Netscape for the PC (I haven't checked 2.0) reserved a smaller
color cube.  And some versions of Netscape (old versions for X, for
instance) didn't use a color cube at all, but instead used a first-fit
algorithm, allocating colors as needed.

Finally, the kicker:   Netscape 1.1 for the PC appears to use a different
color cube for backgrounds than what it uses for images.  Netscape 1.1 on
the PC doesn't render background colors with "99" in triplets correctly
except within images (e.g. as the transparent color).  Instead, it
apparently thinks it has, e.g., A0-based triplets available, and dithers
other nearby values.  This bug does NOT exist in Netscape 2.0 for the PC.

To return to Justie's posting, #009999 should work fine on most PCs running
2.0, just as it does on most Macs; #BBBBBB may get dithered.  Justie's
pages looked fine to me when viewed on a PC running 2.0.  However, sure
enough, both #009999 and #BBBBBB look wrong as the background color on PCs
running Netscape 1.1.  Given the rapidity that 2.0 is replacing 1.1, I
wouldn't worry about the problem if I were Justie.

 JQ Johnson                      office: 115F Knight Library
 Academic Education Coordinator  e-mail: jqj at darkwing.uoregon.edu
 1299 University of Oregon       voice: 541-346-1746; fax: 541-346-3485
 Eugene, OR  97403-1299          <URL:http://darkwing.uoregon.edu/~jqj/>




More information about the Web4lib mailing list