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


The Palette Paradigm

Palettes are easy to create, either as resources or as data structures within your application. Once you create a palette and attach it to a particular window, the Palette Manager manages the window's colors. Whenever your window is activated, the Palette Manager checks each graphics device that your window overlaps and ensures that your colors are available. In allocating colors for your window, the Palette Manager takes into account the importance you place on the various colors in the palette as well as the capabilities of the display devices your window touches.

There are several ways to create a palette. You can do any of the following:

If you create a palette resource for a window in your application, and you assign the same ID to the resource and to the window, the Window Manager automatically calls the Palette Manager to attach the palette to the window when the window is first opened. If you create a palette in code (or from a resource that does not have the same ID as a window), you use the SetPalette or NSetPalette function to attach the palette to a particular window. If you wish, you can create a default palette to use for all windows in your application. You can create a default resource (a resource of type 'pltt' with ID = 0) from which to create the default palette or you can use the SetPalette or NSetPalette function to assign a default palette. See "Designating a Default Palette for Your Application" (page 1-29) for information on how to do this.

In the palette resource, or in the palette that you create, you specify the RGB colors your application needs. You can indicate whether each color must be matched exactly and, if not, how close a match is required. You can tailor your palettes to different possible video devices--indicating, for example, that certain colors in the palette should be used with 4-bit pixel depths, that a different set should be used with 8-bit pixel depths, and that neither set should be used with grayscale devices.

The Palette Manager can handle different screen depths across multiple devices. If the user moves your application window so that it overlaps one grayscale screen, one indexed-color screen, and one direct-color screen, the Palette Manager chooses appropriate grays and colors for all three.

The Palette Manager has access to all palettes used by all windows throughout the system. A set of default color tables for devices of various depths ensures that the Palette Manager always returns to a known set of colors when an application terminates. When your application begins executing, it executes in an environment equipped with as broad a range of colors or grays as the hardware allows; that is, a broad range of colors is always provided but the number of actual colors is limited by the pixel depth of the screen. For example, the default color table for a 4-bit pixel depth screen provides a range of 16 colors, the default color table for a 16-bit pixel depth screen provides a range of 256 colors, and so on.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 NOV 1996