Important: The information in this document is obsolete and should not be used for new development.
MyColorSyncDataTransfer
Application-defined function that transfers profile data from the format for embedded profiles to disk file format or vice versa. Used by PostScript functions to transfer data from a profile to text format usable by a PostScript driver.This application-supplied function must conform to the following declaration, although the function name is arbitrary:
pascal OSErr MyColorSyncDataTransfer ( long command, long *size, void *data, void *refCon);
command- The command with which the
MyColorSyncDataTransferfunction is called. This command specifies the operation the function is to perform.size- A pointer to a size value. On input, the size in bytes of the data to transfer. On output, the size of the data actually transferred.
data- A pointer to the buffer supplied by the ColorSync Manager to use for the data transfer.
refCon- A reference constant that holds the application data passed in from the
CMFlattenProfilefunction, theCMUnflattenProfilefunction, or theCMGetPS2ColorSpace,CMGetPS2ColorRenderingIntent, orCMGetPS2ColorRenderingfunctions. Each time the CMM calls yourMyColorSyncDataTransferfunction, it passes this data to the function.- function result
- A result code of type OSErr. See "Result Codes" (page 3-174) for a list of ColorSync-specific result codes.
DISCUSSION
YourMyColorSyncDataTransferfunction is called to flatten and unflatten profiles or to transfer PostScript-related data from a profile to the PostScript format to send to an application or device driver.The ColorSync dispatcher and the CMM communicate with the
MyColorSyncDataTransferfunction using the command parameter to identify the operation to perform. To read and write profile data, your function must the support the following commands:openReadSpool,openWriteSpool,readSpool,writeSpool, andcloseSpool.You determine the behavior of your
MyColorSyncDataTransferfunction. This section describes how your function might handle the flattening and unflattening processes.FLATTENING A PROFILE
The ColorSync Manager calls the specified profile's preferred CMM when an application calls theCMFlattenProfilefunction to transfer profile data embedded in a graphics document.The ColorSync Manager determines if the CMM supports the
CMFlattenProfilefunction. If so, the ColorSync Manager dispatches theCMFlattenProfilefunction to the CMM. If not, ColorSync calls the default Apple CMM, dispatching theCMFlattenProfilefunction to it.The CMM communicates with the
MyColorSyncDataTransferfunction using a command parameter to identify the operation to perform. The CMM calls your function as often as necessary, passing to it on each call any data transferred to the CMM from theCMFlattenProfilefunction'srefConparameter.The ColorSync Manager calls your function with the following sequence of commands:
openWriteSpool,writeSpool, andcloseSpool. Here is how you should handle these commands:
As part of this process, your function can embed the profile data in a graphics document, for example, a PICT file or a TIFF file. For example, your
- When the CMM calls your function with the
openWriteSpoolcommand, you should perform any initialization required to write profile data you receive from the CMM to a buffer or file.- The CMM will call your function with the
writeSpoolcommand as many times as necessary to transfer all the profile data to you. Each time you are called, you should receive the data and write it to your buffer or file, returning in thesizeparameter the number of bytes of data you actually accepted.- When the CMM calls your function with the
closeSpoolcommand, you should perform any required cleanup processes.
MyColorSyncDataTransferfunction can call the QuickDrawPicCommentfunction to embed the flattened profile in a picture.UNFLATTENING A PROFILE
When an application calls theCMUnflattenProfilefunction to transfer a profile that was embedded in a graphics document to an independent disk file, the ColorSync dispatcher calls yourMyColorSyncDataTransferfunction to obtain the preferred CMM of the profile to flatten. The ColorSync Manager calls your function with the following sequence of commands:openReadSpool,readSpool,closeSpool. Here is how you should handle these commands:
The preferred CMM is stored in the profile header's
- When the CMM calls your function with the
openReadSpoolcommand, you should perform any initialization required to read from the embedded profile format.- The CMM will call your function with the
readSpoolcommand as many times as necessary, directing your function to extract the profile data from the embedded format in the image file and return it to the CMM in thedatabuffer. The CMM passes in thesizeparameter the number of bytes of data you should return. Each time your function is called, it should read and return the data, also returning in thesizeparameter the number of bytes of data you actually returned to the CMM.- When the CMM calls your function with the
closeSpoolcommand, you should perform any required cleanup processes.
CMMTypefield. TheMyColorSyncDataTransferfunction must be able to buffer at least 8 bytes of data to hold theCMMTypefield value.The ColorSync Manager determines if the CMM supports the
CMUnflattenProfilefunction. If so, the ColorSync Manager calls the preferred CMM to dispatch theCMUnflattenProfilefunction to it. If not, the ColorSync Manager calls the default Apple CMM to dispatch theCMUnflattenProfilefunction to it.The CMM calls the
MyColorSyncDataTransferfunction, supplied by the calling application, to unflatten the profile data and write it to a disk file. The CMM calls the function as often as necessary, passing to it on each call any data transferred to the CMM from theCMUnflattenProfilefunction'srefConparameter.