Important: The information in this document is obsolete and should not be used for new development.
MyCMMatchBitmap
Handles thekCMMMatchBitmaprequest by matching the colors of the source image bitmap to the color gamut of the destination profile.A CMM should respond to the
kCMMMatchBitmaprequest code, but it is not required to do so. The ColorSync Manager sends this request code to your CMM on behalf of an application or device driver that called theCWMatchBitMapfunction or high-level QuickDraw operations. The ColorSync Manager dispatches this request to the Component Manager, which calls your CMM to service the request. A CMM typically responds to thekCMMMatchBitmaprequest code by calling a CMM-defined function (for example,MyCMMatchBitmap) to handle the request.The MyCMMatchBitmap function is a color management module-defined subroutine.
pascal CMError MyCMMatchBitmap( ComponentInstance CMSession, const CMBitmap *bitmap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *matchedBitmap);
CMSession- A handle to your CMM's storage for the instance of your component associated with the calling application or device driver.
bitmap- A pointer to the bitmap containing the source image data whose colors your function must match.
progressProc- A pointer to a callback function supplied by the calling application or device driver that monitors the color-matching progress or aborts the operation as your function matches the bitmap colors. Your
MyCMMatchBitmapfunction must call this function periodically to allow it to report progress to the user.refCon- A reference constant passed from the calling application or driver, which your
MyCMMatchBitmapfunction must pass through as a parameter to calls it makes to theMyCMBitmapCallBackProcfunction.matchedBitmap- A pointer to a bitmap in which your function stores the resulting color-matched image. The calling program allocates the pixel buffer pointed to by the
imagefield of theCMBitmapstructure. If this value isNULL, then yourMyCMMatchBitmapfunction must match the bitmap colors in place.- function result
- A result code of type CMError. See "Result Codes" (page 3-172) for a list of ColorSync-specific result codes.
DISCUSSION
If your CMM supports this request code, yourMyCMMatchBitmapfunction should be prepared to receive any of the bitmap types defined by the ColorSync Manager. YourMyCMMatchBitmapfunction must match the colors of the source image bitmap pointed to bybitmapto the color gamut of the destination profile using the profiles specified by a previouskNCMMInit,kCMMInit, orkCMMConcatInitrequest to your CMM. If thematchedBitmapparameter points to a bitmap, you should store the resulting color-matched image in that bitmap. Otherwise, you should store the resulting color-matched image in the source bitmap pointed to by thebitmapparameter. The color-matched bitmap image your function creates is returned to the calling application or driver.Before the Component Manager calls your CMM with a ColorSync request to match the colors of a bitmap, it calls your CMM with a
kNCMMInit,kCMMInit, orkCMMConcatInitrequest, passing your CMM references to the profiles to use for the color-matching session and requesting that your CMM initialize the session.If the Component Manager calls your CMM with a ColorSync
kNCMMInitorkCMMInitrequest, it passes references to the source and destination profiles to use for the color-matching session. If it calls your CMM with the ColorSynckCMMConcatInitrequest code, it passes a pointer to an array of typeConcatProfileSetcontaining a set of profiles or a device-linked profile specified by the calling program to use for the color-matching session. For information about theConcatProfileSetdata type, see "Concatenated Profile Set Structure" (page 3-46).When the Component Manager calls your CMM with the
kCMMMatchColorsrequest code, it passes to your CMM in theCMSessionparameter a handle to your CMM's storage for the calling applications's component instance. YourMyCMMatchBitmapfunction should use the profile data you set in your storage for this component instance to perform the color matching. If you used some other method to store profile data for this component instance when you initialized the session, you should obtain the profile data you require for the color matching from that storage.Your
MyCMMatchBitmapfunction must call the progress function supplied by the calling application or device driver at regular intervals to allow it to report progress to the user on the color-matching session. YourMyCMMatchBitmapfunction should monitor the progress function for a returned value oftrue, which indicates that the user interrupted the color-matching process. In this case, you should terminate the color-matching process. The Apple-supplied CMM calls theMyCMBitmapCallBackProcfunction approximately every half-second, unless color matching takes less time; this happens when there is a small amount of data to match.Here is the prototype for the
MyCMBitmapCallBackProcfunction pointed to by theprogressProcparameter:
pascal Boolean MyCMBitmapCallBackProc ( long progress, void *refCon);Each time yourMyCMMatchBitmapfunction calls theMyCMBitmapCallBackProcfunction, it must pass to the function any data stored in the reference constant. When the Component Manager calls your CMM with thekCMMMatchBitmaprequest code, it passes to your CMM the reference constant from the calling program.Each time your function calls the
MyCMBitmapCallBackProcfunction, your function must pass it a byte count in theprogressparameter identifying the remaining number of bytes. The last time yourMyCMMatchBitmapfunction calls theMyCMBitmapCallBackProcfunction, it must pass a byte count of 0. A byte count of 0--meaning there is no more data to match--indicates the completion of the matching process and signals the progress function to perform any cleanup operations it requires.If the source profile's
dataColorSpacefield value and thespacefield value of the source bitmap pointed to by thebitmapparameter do not specify the same data color space, your function should terminate the color-matching process and return an error code.Also, if the destination profile's
dataColorSpacefield value and thespacefield value of the resulting bitmap pointed to by thematchedBitmapparameter do not specify the same data color space, your function should terminate the color-matching process and return an error code.If your CMM does not support a bitmap type that you receive, you can return an unimplemented error. In this case, the ColorSync Manager unpacks the colors of the bitmap and calls your
CMMMatchColorsfunction, passing it the bitmap colors in a color list. You should avoid defaulting to this behavior, if possible, because it incurs overhead and slows down performance.