Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Advanced Color Imaging on the Mac OS /
Chapter 1 - Palette Manager / About the Palette Manager


How the Palette Manager Allocates Colors for Display

The colors available when your application is running depend on the pixel depths and color capabilities that the attached cards and screens can support, as well as what those devices are actually set to by the system or by the user.

Since your palette may define more colors than the hardware can display, the Palette Manager allocates device color-table entries for your requests according to the priority of their usage. Prioritizing occurs when the ActivatePalette function is called, which occurs automatically when your window becomes the frontmost window. (You may also call ActivatePalette yourself after changing one or more of the palette's colors or usage categories.)

The Palette Manager first allocates animated colors that are also specified as explicit. Colors that are specified as both tolerant and explicit are allocated next.

The Palette Manager allocates animated colors next. Starting with the first entry in your window's palette (entry 0), the Palette Manager checks to see if it is an animated entry. The Palette Manager checks each animated entry to see that the entry has a reserved index for each appropriate device and selects and reserves an index if needed. This process continues until all animated color requests have been satisfied or until the available indexes are exhausted.

The Palette Manager handles tolerant colors next. It assigns each tolerant color an index until all tolerant color requests have been satisfied. The Palette Manager then calculates for each entry the difference between the desired color and the color associated with the selected index. If the difference exceeds the tolerance you have specified, the Palette Manager marks the selected device entry to be changed to the desired color.

Since explicit colors designate index values, not the colors at those index locations, and since courteous colors are amenable to being assigned any RGB value, neither is considered during prioritizing (except for explicit combined with animated).

When the Palette Manager has matched as many animated and tolerant entries as possible, it checks to see if the current device color table is adequate. If modifications are needed, the Palette Manager overrides any calls made to the Color Manager outside the Palette Manager and then calls the Color Manager to change the device's color environment accordingly (with the SetEntries function).

Finally, if the color environment on a given device has changed, the Palette Manager checks to see if this change has affected any other window in the system. If another window is affected, the Palette Manager checks that window to see if it specifies an update in the case of such changes. Applications can use the SetPalette, NSetPalette, or SetPaletteUpdates function to specify whether a window should be updated when its environment has been changed because of actions by another window. (If so, the InvalRect function, described in the "Window Manager" chapter of Inside Macintosh: Macintosh Toolbox Essentials, updates the window using the boundary rectangle of the device that has been changed.)


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 NOV 1996