palettes, palettes, palettes


[ Zettels Traum ] [ search / suche ]

von dp am 15.Maerz 97 um 17:11:44:

zu: Perlen aus dem Strom der Nachrichten im direct_L von Daniel am 22.Dezember 96 um 02:00:59:

There have been so many questions about palettes lately I am
re-posting a message originally sent some time ago by Daniel T. Griscom
which answered a lot of my questions, and I hope will answer many
of the questions out there now.
Thanks for the research Daniel. Hope you don't mind me re-sending it.

**********************************************

- The Mac "likes" to have color 0 be white and color 255 to be black.
"Likes" means that for the most part the OS can handle palettes where this
isn't true, but some application software requires it. Director 5, in
particular, won't let you edit colors 0 and 255 to be anything but
white/black, and in fact when you try to import an image where this isn't
true Director will require you to remap it to another, conforming palette.
So, for our purposes, 0 is white and 255 is black.

All other color positions may be played with at will; your projects will
have the correct colors on the Mac. If the colors the system wants aren't
available then it will default to a black-and-white appearance; the system
won't mess with Director's colors. One note: if "Animate in Background" is
turned on and you bring another app to the front, the application's colors
may be messed up by Director insisting on its set of colors.

- Windows "likes" to have color 0 be black and color 255 to be white (I
don't know how strong "likes" is). It also considers the additional 18
colors from 1 to 9 and from 246 to 254 to be fair game for system interface
use; by default the low number colors are dark pastels and the high number
colors are bright primaries.

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?

a) 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.

b) 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.

Daniel T. Griscom




Dazu:























D. Plänitz