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 7 - Color Manager / Using the Color Manager


Customizing Complement Functions

Some specialized color applications may need to modify the way in which the Color Manager calculates the inverse, or complement, of a color. The Color Manager's default method for inverting a color is to invert the bit values of the RGBColor data structure. For colors in which at least one component has very low or very high values this method produces expected (or at least discernible) results. A pure green, for example, with RGB color values of 0x0000, 0xFFFF, and 0x0000, inverts to magenta, with RGB color values of 0xFFFF, 0x0000, and 0xFFFF. But midrange values do not change by much: a component value of 0x7FFF, for example, inverts to 0x8000, which is an indiscernible difference. A gray value always inverts to another gray, which may or may not be what your application needs.

Your application can supply a custom complement function to find the inverse of a specified color. The Color Manager keeps complement functions in a linked list beginning in the GDevice data structure's gdCompProc field. Each link is a CProcRec data structure, which has the format shown below.

struct CProcRec {
   Handle            nxtComp; /* handle to next CProcRec */
   ColorComplementProcPtrcompProc;/* pointer to complement 
                                 function */
};
typedef struct CProcRec CProcRec;
You install a complement function with the AddComp function. When your application is done using it, be sure to remove it with the DelComp function.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 NOV 1996