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: Imaging With QuickDraw /
Chapter 7 - Pictures / Pictures Reference
Application-Defined Routines /


MyCalcColorTable

Your color-picking method ('cpmt') resource should include a routine that selects as many colors as are requested by your application from the color bank for a picture or pixel map and then fills these colors into an array of ColorSpec records.

Here is how you would declare this routine if it were a Pascal function named MyCalcColorTable:

FUNCTION MyCalcColorTable (dataRef: LongInt; 
                           colorsRequested: Integer; 
                           colorBankPtr: Ptr; 
                           VAR resultPtr: CSpecArray): OSErr;
dataRef
A handle to any data your method needs. Your application initially creates this handle using the MyInitPickMethod routine (explained on page 7-61).
colorsRequested
The number of colors requested by your application to be gathered for examination in a ColorTable or Palette record.
colorBankPtr
If your MyInitPickMethod routine (described on page 7-61) returned either the colorBankIsExactAnd555 or colorBankIs555 constant, then this parameter contains a pointer to the 5-5-5 histogram that describes all of the colors in the picture, pixel map, or bitmap being examined. (The format of the 5-5-5 histogram is explained in the routine description for the MyInitPickMethod routine.) Your MyCalcColorTable routine should examine these colors and then, using its own criterion for selecting the colors, fill in an array of ColorSpec records with the number of colors specified in the colorsRequested parameter.
If your MyInitPickMethod routine returned the colorBankIsCustom constant, then the value passed in this parameter is invalid. In this case, your MyCalcColorTable routine should use the custom color bank that your application created (as explained in the routine description for the MyRecordColors routine on page 7-63) for filling in an array of ColorSpec records with the number of colors specified in the colorsRequested parameter.
Your MyCalcColorTable function should return a pointer to this array of ColorSpec records in the next parameter.
resultPtr
A pointer to the array of ColorSpec records to be filled with the number of colors specified in the colorsRequested parameter. The Picture Utilities function that your application initially called places these colors in a Palette record or ColorTable record, as specified by your application.
DESCRIPTION
Selecting from the color bank created for the picture, bitmap, or pixel map being examined, your MyCalcColorTable routine should fill an array of ColorSpec records with the number of colors requested in the colorsRequested parameter and return this array in the resultPtr parameter. If your MyCalcColorTable routine generates any error, it should return the error as its function result.

If more colors are requested than the picture contains, fill the remaining entries with black (0000 0000 0000).

The colorBankPtr parameter is of type Ptr because the data stored in the color bank is of the type specified by your MyInitPickMethod routine (described on page 7-61). Thus, if you specified colorBankIs555 in the colorBankType parameter, the color bank would be an array of integers. However, if the Picture Utilities support other data types in the future, the colorBankPtr parameter could point to completely different data types.

SPECIAL CONSIDERATIONS
Always coerce the value passed in the colorBankPtr parameter to a pointer to an integer. In the future you may need to coerce this value to a pointer of the type you specify in your MyInitPickMethod function.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996