Important: The information in this document is obsolete and should not be used for new development.
MyCMMFlattenProfile
Handles thekCMMFlattenProfile
request by extracting profile data from the profile to flatten and passing it to the specified function.A CMM may respond to the
kCMMFlattenProfile
request 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 theCMFlattenProfile
function. The ColorSync Manager dispatches this request to the Component Manager, which calls your CMM to service the request. A CMM that handles thekCMMFlattenProfile
request code typically responds by calling a CMM-defined function (for example,MyCMMFlattenProfile
).The MyCMMFlattenProfile function is a color management module-defined subroutine.
pascal CMError MyCMMFlattenProfile ( ComponentInstance CMSession, CMProfileRef prof, unsigned long flags, 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.
prof
- A reference to the profile to flatten.
flags
- Reserved for future use.
proc
- A pointer to the
MyColorSyncDataTransfer
function supplied by the calling application or device driver to perform the low-level data transfer. YourMyCMMFlattenProfile
function calls this function repeatedly as necessary until all the profile data is transferred.refCon
- A reference constant containing data specified by the calling application or device driver.
- 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 flattening 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
MyCMMFlattenProfile
function must extract the profile data from the profile to flatten, identified by theprof
parameter, and pass the profile data to the function specified in theproc
parameter.Your
MyCMMFlattenProfile
function calls theMyColorSyncDataTransfer
function supplied by the calling application. Here is the prototype for theMyColorSyncDataTransfer
function pointed to by theproc
parameter:
pascal OSErr MyColorSyncDataTransfer( long command, long *size, void *data, void *refCon);YourMyCMMFlattenProfile
function communicates with theMyColorSyncDataTransfer
function using a command parameter to identify the operation to perform. Your function should call theMyColorSyncDataTransfer
function first with theopenWriteSpool
command to direct theMyColorSyncDataTransfer
function to begin the process of writing the profile data you pass it in thedata
buffer. Next, you should call theMyColorSyncDataTransfer
function with thewriteSpool
command. After theMyColorSyncDataTransfer
function returns in thesize
parameter the amount of data it actually wrote, you should call theMyColorSyncDataTransfer
function again with thewriteSpool
command, repeating this process as often as necessary until all the profile data is transferred. After the data is transferred, you should call theMyColorSyncDataTransfer
function with thecloseSpool
command.When your function calls the
MyColorSyncDataTransfer
function, it passes in thedata
buffer the profile data to transfer to theMyColorSyncDataTransfer
function and the size in bytes of the buffered data in thesize
parameter. TheMyColorSyncDataTransfer
function may not always write all the data you pass it in thedata
buffer. Therefore, on return theMyColorSyncDataTransfer
function command passes back in thesize
parameter the number of bytes it actually wrote. Your function keeps track of the number of bytes of remaining profile data.Your
MyCMMFlattenProfile
function is responsible for obtaining the profile data from the profile, allocating a buffer in which to pass the data to theMyColorSyncDataTransfer
function, and keeping track of the amount of remaining data to transfer to theMyColorSyncDataTransfer
function.Each time your
MyCMMFlattenProfile
function calls theMyColorSyncDataTransfer
function, you pass it the reference constant passed to your function in the reference constant parameter.