Important: The information in this document is obsolete and should not be used for new development.
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 ofColorSpec
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
orPalette
record.colorBankPtr
- If your
MyInitPickMethod
routine (described on page 7-61) returned either thecolorBankIsExactAnd555
orcolorBankIs555
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 theMyInitPickMethod
routine.) YourMyCalcColorTable
routine should examine these colors and then, using its own criterion for selecting the colors, fill in an array ofColorSpec
records with the number of colors specified in thecolorsRequested
parameter.- If your
MyInitPickMethod
routine returned thecolorBankIsCustom
constant, then the value passed in this parameter is invalid. In this case, yourMyCalcColorTable
routine should use the custom color bank that your application created (as explained in the routine description for theMyRecordColors
routine on page 7-63) for filling in an arrayof ColorSpec
records with the number of colors specified in thecolorsRequested
parameter.- Your
MyCalcColorTable
function should return a pointer to this array ofColorSpec
records in the next parameter.resultPtr
- A pointer to the array of
ColorSpec
records to be filled with the number of colors specified in thecolorsRequested
parameter. The Picture Utilities function that your application initially called places these colors in aPalette
record orColorTable
record, as specified by your application.DESCRIPTION
Selecting from the color bank created for the picture, bitmap, or pixel map being examined, yourMyCalcColorTable
routine should fill an array ofColorSpec
records with the number of colors requested in thecolorsRequested
parameter and return this array in theresultPtr
parameter. If yourMyCalcColorTable
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 typePtr
because the data stored in the color bank is of the type specified by yourMyInitPickMethod
routine (described on page 7-61). Thus, if you specifiedcolorBankIs555
in thecolorBankType
parameter, the color bank would be an array of integers. However, if the Picture Utilities support other data types in the future, thecolorBankPtr
parameter could point to completely different data types.SPECIAL CONSIDERATIONS
Always coerce the value passed in thecolorBankPtr
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 yourMyInitPickMethod
function.