[comp.sys.mac.programmer] Finding the closest matching palette entry

lipa@POLYA.STANFORD.EDU (William Lipa) (08/16/88)

I am writing an application which prompts the user for a color to use when
drawing objects. I want to make sure that whatever color the user requests is
given to him exactly.

Clearly, this might change the appearance of previously drawn items by
usurping their entry in the color table. That's OK, but if some other color
has to be set to the user's new color, I want it to be the closest possible
color. For example, if the picture has blue and red things, and the user
chooses light blue, I want the blue things to change to light blue and not the
red.

Also, I would like to use the Palette Manager as much as possible since that
seems to handle things like multiple screens easily. Is there a way to do what
I want with the Palette Manager? From reading IM V, it doesn't seem as though
there is an easy way to find the closest matching palette entry from a given
rgb value.

Any advice is much appreciated.

Bill Lipa
lipa@polya.stanford.edu