Important: The information in this document is obsolete and should not be used for new development.
MyCMMUnflattenProfile
Handles thekCMMUnflattenProfilerequest by creating a uniquely named file in the temporary items folder to store the profile data.A CMM may respond to the
kCMMUnflattenProfilerequest code, but it is not required to do so. Most CMMs can rely on the default Apple CMM to handle this request code adequately. The ColorSync Manager sends this request code to your CMM on behalf of an application or device driver that called theCMUnflattenProfilefunction. The ColorSync Manager dispatches this request to the Component Manager, which calls your CMM to service the request. A CMM that handles thekCMMUnflattenProfilerequest code typically responds by calling a CMM-defined function (for example,MyCMMUnflattenProfile).The MyCMMUnflattenProfile function is a color management module-defined subroutine.
pascal CMError MyCMMUnflattenProfile ( ComponentInstance CMSession, FSSpec *resultFileSpec, CMFlattenUPP proc, void *refCon);
CMSession- A handle to your CMM's storage for the instance of your component associated with the calling application or device driver.
resultFileSpec- A pointer to a file specification for the profile file. This is a temporary file specification. You must create this temporary file, which is returned to the calling application or device driver. The calling application or driver is responsible for disposing of the file when finished with it.
proc- A pointer to a function supplied by the calling application or device driver to perform the low-level data transfer. Your
MyCMMFlattenProfilefunction calls this function repeatedly as necessary until all the profile data is transferred.refCon- A reference constant containing data specified by the calling application program.
- function result
- A result code of type CMError. See "Result Codes" (page 3-172) for a list of ColorSync-specific result codes.
DISCUSSION
Only in rare circumstances should a custom CMM need to support this request code. The process of unflattening a profile is complex, and the default Apple CMM handles this process adequately for most cases. A custom CMM might respond to this request code if the CMM provides special services such as profile data encryption or compression, for example. Read the rest of this description if your CMM handles this request code.Your
MyCMMUnflattenProfilefunction must create a file with a unique name in which to store the profile data. (You should create this file in the temporary items folder.) The ColorSync Manager returns the temporary file specification to the calling application or device driver.To obtain the profile data, your
MyCMMUnflattenProfilefunction calls theMyColorSyncDataTransferfunction supplied by the calling application or device driver. Here is the prototype for theMyColorSyncDataTransferfunction pointed to by theprocparameter:
pascal OSErr MyColorSyncDataTransfer ( long command, long *size, void *data, void *refCon);Before calling theMyColorSyncDataTransferfunction, yourMyCMMUnflattenProfilefunction must allocate a buffer to hold the profile data returned to you from theMyColorSyncDataTransferfunction in thedataparameter.Your
MyCMMUnflattenProfilefunction communicates with theMyColorSyncDataTransferfunction using a command parameter to identify the operation to perform. Your function should call theMyColorSyncDataTransferfunction first with theopenReadSpoolcommand to direct theMyColorSyncDataTransferfunction to begin the process of transferring data. Following this, you should call theMyColorSyncDataTransferfunction with thereadSpoolcommand as often as necessary until theMyColorSyncDataTransferfunction has passed your function all the profile data from the graphics file. After you have received all the profile data, your function should call theMyColorSyncDataTransferfunction with thecloseSpoolcommand.Each time you call the
MyColorSyncDataTransferfunction, you should pass it a pointer to thedatabuffer you created, the size in bytes of the profile data to return to you in the buffer, and the reference constant passed to you from the calling application.On return, the
MyColorSyncDataTransferfunction passes to you the profile data that your function must write to the temporary file that you created for the new profile file. TheMyColorSyncDataTransferfunction will not always transfer the number of bytes of profile data you requested. Therefore, theMyColorSyncDataTransferfunction returns in thesizeparameter the number of bytes of profile data it actually returned in thedatabuffer.The profile file you create is returned to the calling application or device driver in the
resultFileSpecparameter. YourMyCMMUnflattenProfilefunction must identify the profile size and maintain a counter tracking the amount of data transferred to you and the amount of remaining data to determine when to call theMyColorSyncDataTransferfunction with thecloseSpoolcommand. To determine the profile size, your function can obtain the profile header, which specifies the size.The calling application or device driver uses the reference constant to pass information to the
MyColorSyncDataTransferfunction that the function requires to transfer the data.