Optimum Cross Platform 8-bit Palettes

Date: Mon, 06 Jan 1997 20:04:09 -0500
From: Daniel Griscom <griscom@suitable.com>
Subject: Possible info for Director Web Tips
I've been doing research on custom 8-bit palettes for Director that work on both the Mac and Windows, and I'd like to get comments on what I've discovered and deduced. I've had to do some extrapolation and guessing at times; please let me know if I've missed/misstated something, or if there are some details that could be stated better.

If this message is too long, send me email instead of posting; don't waste everyone's time saying that I've wasted everyone's time.

If you look at the "System - Win" palette in Director 5 (Mac or Win), you'll find that the opposite of what I said is true: the low 10 colors are bright, with number 0 being white, and the high 10 colors are dim, with number 255 being black. Plus, colors 8, 9, 246 and 247 are marked as "reserved", and so aren't used when images are mapped to that palette. The actual colors are (in decimal RGB):

Index   Red     Green   Blue
0       255     255     255
1       0       255     255
2       255     0       255
3       0       0       255
4       255     255     0
5       0       255     0
6       255     0       0
7       128     128     128
8       160     160     164  
9       255     251     240  
 ... 236 other colors ...
246     166     202     240  
247     192     220     192  
248     192     192     192
249     0       128     128
250     128     0       128
251     0       0       128
252     128     128     0
253     0       128     0
254     128     0       0
255     0       0       0
The same set of colors can be found in DeBabelizer 1.6.5 for the Mac in the "Windows Paintbrush 256" palette, except that the order is reversed, the "236 other colors" are all black, and all the "128"s in Director's colors 249 through 254 become "191"s in DeBab's colors 1 through 6. One message in Direct-L noted that "some of the static interface colors are darker in Win95 than in Win3.1", so perhaps DeBabelizer's color palette is based on Win3.1's palette.

The reason for Director having the opposite color order from Windows is that, before displaying an image, DFW reverses both the color order in the requested palette and the color order in displayed images. In other words, the color with index X in a custom palette is actually written into the display palette at index (255 - X), and each pixel in each displayed image is subtracted from 255 before displaying (sounds complex, but I'm sure it takes few CPU cycles). Also, when importing images, PC format images (such as .BMP) have their palettes and pixels reversed before being added to the cast, preparing them to be reversed again for display. All this tapdancing means that a single set of images and palettes can work on both platforms.

Note that all the colors in this list "make sense" (are all combinations of 0 and one of 128, 192 or 255) except colors 8, 9, 246 and 247, which are the "reserved" colors in Director's palette. I believe that if a Windows user creates a custom user interface "appearance" with custom colors, then Windows may change these four color slots in order to show the custom colors. If this is true then these four colors are hazardous (using them on a machine with custom appearance colors would have bad results). I don't know if the other 16 colors are liable to being changed (does anyone know?)

You can actually play with all 254 colors in Windows (except black and white) as long as you NEVER have any system component (e.g. dialog, alert, another application, or QuickTime controller) visible. If you've changed the reserved 20 colors and a system component appears then Windows will egregiously change palette colors to match its needs (breaking colors in your project; once this happens colors will stay broken until you do some magic such as "pause/resume").

Whew.

So, what does all this mean?

  1. If you are SURE your images are the only thing that will be displayed, then make your own custom palette using all 254 colors (if developing on the PC leave 0 as black and 255 as black; if on the Mac then leave 0 as white and 255 as black). Remember, though, that once anything like an alert is displayed then your colors may be messed up. Caveat color.

  2. The rest of us should take the "System - Win" palette from Director 5 (if you're developing on the PC outside of Director, reverse the order of the palette's colors). Create a 236-color superpallette from your source material, and graft the 236 colors into the middle of the "System - Win" palette (leaving the first 10 and last 10 as is). Mark "some" of the colors as reserved, so that none of your images uses them. (What is "some"? At least colors 8, 9, 246 and 247; maybe colors 1-9 and 246-254, assuming Windows leaves white and black alone; perhaps even colors 0-9 and 246-255. Does anyone know which is right?) Now, convert all of your source material to this carefully honed palette, import into Director, and enjoy.
So, the remaining questions are: