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 ofColorSpecrecords.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
MyInitPickMethodroutine (explained on page 7-61).colorsRequested- The number of colors requested by your application to be gathered for examination in a
ColorTableorPaletterecord.colorBankPtr- If your
MyInitPickMethodroutine (described on page 7-61) returned either thecolorBankIsExactAnd555orcolorBankIs555constant, 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 theMyInitPickMethodroutine.) YourMyCalcColorTableroutine should examine these colors and then, using its own criterion for selecting the colors, fill in an array ofColorSpecrecords with the number of colors specified in thecolorsRequestedparameter.- If your
MyInitPickMethodroutine returned thecolorBankIsCustomconstant, then the value passed in this parameter is invalid. In this case, yourMyCalcColorTableroutine should use the custom color bank that your application created (as explained in the routine description for theMyRecordColorsroutine on page 7-63) for filling in an arrayof ColorSpecrecords with the number of colors specified in thecolorsRequestedparameter.- Your
MyCalcColorTablefunction should return a pointer to this array ofColorSpecrecords in the next parameter.resultPtr- A pointer to the array of
ColorSpecrecords to be filled with the number of colors specified in thecolorsRequestedparameter. The Picture Utilities function that your application initially called places these colors in aPaletterecord orColorTablerecord, as specified by your application.DESCRIPTION
Selecting from the color bank created for the picture, bitmap, or pixel map being examined, yourMyCalcColorTableroutine should fill an array ofColorSpecrecords with the number of colors requested in thecolorsRequestedparameter and return this array in theresultPtrparameter. If yourMyCalcColorTableroutine 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
colorBankPtrparameter is of typePtrbecause the data stored in the color bank is of the type specified by yourMyInitPickMethodroutine (described on page 7-61). Thus, if you specifiedcolorBankIs555in thecolorBankTypeparameter, the color bank would be an array of integers. However, if the Picture Utilities support other data types in the future, thecolorBankPtrparameter could point to completely different data types.SPECIAL CONSIDERATIONS
Always coerce the value passed in thecolorBankPtrparameter 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 yourMyInitPickMethodfunction.