Method and system for embedding a device profile into a document and extracting a device profile from a document in a color management system5806081Abstract A method and system for embedding a device profile into a document and extracting a device profile from a document in a color management system. A tagged-element device profile allows for selective access to the device profile. The method of embedding a device profile into a document include allocating memory for a buffer, sending a ready call, transferring the device profile or portions of the device profile into the buffer and writing the same in the document, and lastly, sending a completed call. The method of extracting a device profile from a document includes allocating memory for a buffer, sending a ready call, reading the device profile or portions of the device profile from the document into the buffer and transferring the same to a file, and finally, sending a completed call. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
______________________________________
componentType `prof`
componentSubType `dflt`
componentManufacturer `appl`
______________________________________
As discussed earlier, the Apple-supplied default CMM has a subcomponent type of `appl`. Companies or vendors who create CMMs can register their CMMs with Apple and be assigned a subcomponent type. Search specifications are defined by the following C language code and structure.
______________________________________
typedef
pascal
Boolean (*ProfileFilterProcPtr)(Profile prof, void *refCon);
#if USESROUTINEDESCRIPTORS
typedef UniversalProcPtr ProfileFilterUPP;
#else
typedef ProfileFilterProcPtr ProfileFilterUPP;
#endif
struct ProfileSearchRecord {
OSType CMMType;
OSType profileClass;
OSType deviceColorSpace;
OSType interchangeColorSpace;
unsigned long deviceManufacturer;
unsigned long deviceModel;
unsigned long deviceAttributes›2!;
unsigned long profileFlags;
unsigned long searchMask;
ProfileFilterUPP filter;
};
typedef struct ProfileSearchRecord
ProfileSearchRecord;
______________________________________
The bits of field "Mask" specify corresponding header fields which must match in the search.
______________________________________
#define kMatchProfileCMMType
0x00000001
#define kMatchProfileClass
0x00000002
#define kMatchDeviceSpace 0x00000004
#define kMatchInterchangeSpace
0x00000008
#define kMatchManufacturer
0x00000010
#define kMatchModel 0x00000020
#define kMatchAttributes 0x00000040
#define kMatchProfileFlags
0x00000080
______________________________________
The field "Filter" is a client function which can be used to search on elements outside the header of the device profile, or to implement AND or OR search logic. If "Filter" returns TRUE for a specific device profile, then it is excluded, or filtered, from the search. Color space conversion 52 converts color data between various independent and derived color spaces. In the preferred embodiment, the following independent and derived color spaces are supported: CIEXYZ, CIELab, CIELuv, Yxy, RGB, HLS, HSV, GRAY, CMY, CMYK, and "Hi-fi" color, which is a special purpose multi-component color space intended for commercial printing with multiple inks. Color space conversion 52 preferably converts colors between color spaces within a color family. An example of a color family is CIEXYZ, CIELab, CIELuv and Yxy. FIG. 4 is a pictorial representation of a device profile according to the present invention. A device profile 56 contains at least three sections, a header 58, a tag table 60, and tagged element data 62. Custom profiles may also have additional, private data. Appendix 1 describes in greater detail the types of profiles that may be used in the preferred embodiment. Appendix 1 is a top level view of what tags are required for each profile classification and a brief description of the algorithmic models associated with these classifications. Header 60 defines a set of parameters at the beginning of device profile 56. In the preferred embodiment, header 58 has the following contents and size:
______________________________________
bytes
______________________________________
struct CM2 Header {
unsigned long size; 0-3
OSType CMMType; 4-7
NumVersion profileVersion;
8-11
OSType profileClass; 12-15
OSType dataColorSpace;
16-19
OSType interchangeColorSpace
20-23
CMDateTime dateTime; 24-35
OSType CS2profileSignature;
36-39
OSType platform; 40-43
unsigned long flags; 44-47
OSType deviceManufacturer;
48-51
unsigned long deviceModel; 52-55
unsigned long deviceAttributes›2!;
56-63
unsigned long renderingIntent;
64-67
FixedXYZColor white; 68-79
char reserved›36!;/*for future
80-127
use*/};
______________________________________
The first eight bits of the profile version are the major version number and the next eight bits are for the minor version number. The platform flag indicates the primary platform/operating system of the device. The flags in bytes 44-47 are used to indicate various hints for the CMM such as distributed processing and caching options. The rendering intent may be one of four types in the preferred embodiment. The rendering intent types are perceptual, relative calorimetric, saturation and absolute colorimetric. Device attributes are attributes unique to the particular device setup such as media type. The profile class field indicates the type of device for which the profile is intended. Three standard types are:
______________________________________
`scnr` input devices such as scanners and digital cameras
`mntr` display devices such as CRTs and LCDs
`prtr` output devices such as printers
______________________________________
In addition to the three basic device profile classes, three additional color processing profiles may be used in the preferred embodiment. These profiles provide a standard implementation for use by the CMM in general color processing or for the convenience of CMMs which may use these types to store calculated transforms. These three profile classes are:
______________________________________
`link` device link profiles
`spac` color space conversion profiles
`abst` abstract profiles
______________________________________
Tag table 60 provides a table of contents to tagged element data 62 in device profile 56. Tag table 60 includes a tag signature, address and size for each tagged element data 62. A tag signature acts as a pointer to a specific element in tagged element data 62. In the preferred embodiment, a tag signature is defined as a four byte hexadecimal number. Each tagged element data 62 is a piece of color information that a CMM can use to perform color matching or correction. Examples of tagged element data 62 include gray tone reproduction curve information and the tristimulus values for red, green, and blue. By using tag table 60, tagged element data 62 can be accessed randomly and individually. In this manner, a single element 64 within tagged element data 62 can be accessed and loaded into memory, thereby providing only the information necessary to perform a particular function or process of color matching or to present device information to a user. Providing device information to a user may be accomplished via a user interface implemented by the application or device driver. Appendix 2 provides a list of the calls which can be used to access a profile. Appendix 3 specifies the individual tags which can be used in the preferred embodiment to create a profile. Appendix 4 specifies the type and structure definitions used in the preferred embodiment to create the individual tagged elements. Referring to FIG. 5, a block diagram depicts a method and system for dispatching an element in a device profile according to the present invention. A first memory 66 preferably contains a system folder 68. Within system folder 68 is a profile folder 70. Profile folder 70 preferably contains at least one device profile that may be used with ColorSync.TM. 2.0. In the preferred embodiment, first memory 66 is a main memory in a computer system, one example being a hard drive. A second memory 72 contains at least a portion of a device profile 74. In the preferred embodiment, second memory 72 is any scratch or temporary memory, one example being random access memory (RAM). The portion of device profile 74 within second memory 72 preferably includes header 58, tag table 60, and possibly one element from tagged element data 62, as shown in FIG. 4. When a different element is needed, caller 76 requests a new element and allocates the necessary amount of memory in second memory 72 for the new element. Caller 76 can be a CMM, device driver, application or calibration device. The call used to request an element is stated below.
______________________________________
pascal
CMError
GetProfileElement (Profile prof, OSType tag, long *elementSize, void
*elementData);
______________________________________
In the GetProfileElement call, "Profile prof" is an input parameter that specifies the profile to be accessed. "OSType Tag" is an input parameter that specifies the tag signature for the requested element. "ElementSize" is an input and output parameter, and specifies the size of the element to be copied. "ElementData" is an input and output parameter, and specifies the destination for copying the element. If elementSize is not NULL and elementData is NULL when a call is made, then the size of the element is returned in the *elementSize parameter. If elementSize and elementData are not NULL, then the element is copies to the *elementData parameter. Finally, If elementSize is NULL and elementData is not NULL, the entire element is copied. The method and system of the present invention provides for other functions regarding elements in tagged element data 62. One function is the ability to determine whether or not an element with a specific tag signature exists in the profile. The call for this function is given below.
______________________________________
pascal
CMError
ProfileElementExists(Profile prof, OSType tag, Boolean *found);
______________________________________
The parameter "Boolean *found" is an output parameter, and returns a true if the element exists. "Profile prof" and "OSType tag" are defined above. Another function available in the preferred embodiment provides the ability to access only a part of an element for a specified tag signature. The caller of the function is responsible for allocating memory for storage of the partial element. The call for this function is stated below.
______________________________________
pascal
CMError
GetPartialProfileElement (Profile prof, OSType tag, unsigned long
offset, unsigned long byteCount, void *elementData);
______________________________________
The parameter "unsigned long offset" is an input parameter that specifies where to begin the transfer of data within the element. "Unsigned long byteCount" identifies the number of bytes to transfer. "Profile prof", "OSType tag", and "*elementData" are defined above. A user has the ability to reserve a portion of an element for a specific tag in the preferred embodiment. This function is broken down into two function calls. The first function call is given below.
______________________________________
pascal
CMError
SetProfileElementSize(Profile Prof, OSType tag, unsigned long
elementSize);
______________________________________
This call passes parameters that set the size of the element. The parameter "elementSize" is an input parameter that identifies the total byte size to be reserved for data in an element. This first call must be made prior to making the second function call. The second function call is stated below.
______________________________________
pascal
CMError
SetPartialProfileElement(Profile prof, OSType tag, unsigned long
offset, unsigned long byteCount, void *elementData);
______________________________________
The second function sets part of an element for the specified tag signature. If desired, the second function call may be repeated until the complete element has been transferred to scratch memory. These two function calls provide the color management system of the preferred embodiment with the ability to access or set portions of the data in an element. Additional functions for profile and element access that are implemented in the preferred embodiment are listed in Appendix 2. The modular architecture of the color management system of the preferred embodiment provides for multiple accesses of the same device profile and manipulation of the device profile, or portions of the device profile, while maintaining the integrity of the device profile. FIG. 6 is a block diagram illustrating a method and system for dynamically dispatching device profile data in a computer system according to the present invention. Multiple devices within a computer system may need to access the same device profile at one time. For example, a CMM 78 may need to access the device profile to obtain an element for color matching, as described with reference to FIG. 5. A device driver 80 may access the same device profile to determine what is the preferred CMM in the device profile. Another access may occur because an application software program 82 wants to know whether or not a specific element exists in the device profile. Additional access to the same device profile may be done by other 84. Other 84 may be any other device or software which wants to access the device profile, such as a calibration device. Other 84 may also be a user who wishes to temporarily modify the device profile. As discussed above with reference to FIG. 3, dispatcher 86 provides the overall color management administrative framework and manages the interaction between modules within the color management system. Accesses to device profiles are routed through dispatcher 48. Device profiles are preferably stored in a profile file 88 in the main memory of a computer system. If an access to a device profile involves a modification of the device profile, a temporary copy of the modified device profile is stored in a scratch memory 90. Interaction between profile file 88 and scratch memory 90 are handled by dispatcher 86. Modification of the device profile includes adding, deleting or changing one or more elements in the device profile, or changing information in the header or tag table in the device profile. For example, a user may want color matching to occur when printing a document. However, for this document only, the user wants to use a rendering intent different from the one specified in the device profile. Consequently, the user needs to modify the header in the device profile. This is accomplished via a user interface in the preferred embodiment. A copy of the header with the changed rendering intent flag is stored in scratch memory 90 and referenced when printing the document. The original device profile remains unchanged in profile file 88. Consequently, any other accesses to the header in the same device profile stored in profile file 88 are not affected by the user's temporary modification of the header, since the modified header is stored in scratch memory 90. The modified header will be discarded unless the user requests the device profile be updated. The method and system for dynamically dispatching device profile data can also be implemented in a computer network. The ability to modify the device profile or its contents while maintaining the integrity of the device profile and its contents is useful in a computer network where multiple computer systems can be using the same files or data. In this situation, one computer system preferably can not update, or make lasting changes to the device profile when other systems are accessing the device profile. Referring to FIGS. 7a-b, flowcharts depict a method for embedding a device profile into a document according to the present invention. The process of streaming out a disk-based device profile and embedding it into a document is called flattening. FIG. 7a illustrates the steps performed by the dispatcher (block 86 in FIG. 6) when flattening a device profile. The method begins at block 92 with a client requesting that a device profile be flattened. To request flattening, a client uses the following command in the preferred embodiment.
______________________________________
pascal
CMError
FlattenProfile(Profile prof, long flags, FlattenProcUPP proc,
void *refCon)
______________________________________
This command is discussed in greater detail in Appendix 2. The process then passes to block 94, where the dispatcher determines whether or not the preferred CMM is available. The preferred CMM is the CMM that is specified in the device profile. If the preferred CMM is not available, the process passes to block 96, where the Apple-supplied default CMM is called to flatten the device profile. Additionally, an error condition is returned to the client indicating that the preferred CMM is not available. This step is depicted in block 98. The process then stops, as shown in block 100. Referring again to block 94, if the preferred CMM is available, the dispatcher calls that CMM by making a "CMFlattenProfile" call. This step is shown in block 102. The dispatcher then checks the return code from the CMM to determine whether or not the preferred CMM can flatten the device profile, as depicted in block 104. If the preferred CMM can not flatten the device profile, the dispatcher calls the Apple-supplied default CMM to flatten the profile, and an error condition is returned to the device driver or application software program indicating that the preferred CMM can not flatten the device profile. These steps are illustrated in blocks 106 and 108, respectively. If the preferred CMM can flatten the device profile, the profile is flattened by that CMM, as illustrated in block 110. The process then ends at block 100. FIG. 7b depicts the steps by a CMM when called to flatten a device profile, as illustrated in block 110 in FIG. 7a. In the preferred embodiment, the command used by the dispatcher to call a CMM is given below.
______________________________________
pascal
CMError
CMFlattenProfile(ComponentInstance CMSession, Profile prof,
long flags, FlattenUPP proc, void *refCon)
______________________________________
This command is discussed in greater detail in Appendix 2. The process begins at block 112 with the dispatcher calling a CMM, and thereafter passes to block 114. Block 114 illustrates the determination of whether or not the CMM supports the function of flattening. If the CMM can not flatten the device profile, an error condition is returned to the dispatcher, as shown in block 116. The process then passes to block 118, which depicts the end of the process. If the CMM can flatten the device profile, the process continues at block 120. Block 120 depicts the allocation of scratch memory, preferably RAM, that will act as a data buffer during the flattening process. Next, a determination is made as to whether or not the buffer allocation is successful, as shown in block 122. If the buffer allocation failed because sufficient RAM is not available, the process passes to block 124, where a determination is made as to whether or not the amount of scratch memory is the minimum amount of memory that can be used as a data buffer. The minimum amount of memory is dependent on the total amount of scratch memory and how much is used up by other tasks. If the amount of scratch memory is less than the minimum, an error condition is returned, as shown in block 126. The process then ends at block 118. If the amount of scratch memory is not the minimum, the amount of memory requested is reduced, as illustrated in block 128. In the preferred embodiment, the amount of memory allocation is halved. The process then returns to block 122. Referring again to block 122, if the buffer allocation is successful, a new profile is created by making a "NewProfile" call. This step is shown in block 130. Next, the header is copied into the new profile. Block 132 illustrates this step. The flag passed in the "long flags" parameter of the "FlattenlProfile" command is then read, as shown in block 134. The following flags are available in the preferred embodiment.
______________________________________
AtoBElements
Include elements necessary for the source side of a
matching session. Common case for a document
profile tag
BtoAElements
Include elements necessary for the destination side
of a matching session
intent0 Include elements necessary for rendering intent 0
intent1 Include elements necessary for rendering intent 1
intent2 Include elements necessary for rendering intent 2
qd32KLimit
Flattened CMProfile may not exceed 32K, the limit
for QuickDraw PicComments
______________________________________
Based upon the flag used, the specified elements are copied into the new profile, as shown in block 136. One advantage to the flags is that they allow the elements in the profile to be selectively copied and embedded into a document. This provides a mechanism for choosing the color data which will be included in the new profile. The process continues at block 138, where a "CloseSpool" command is made. Next, the CMM makes a ready call to the client, as shown in block 140. In the preferred embodiment, the ready call is an "OpenWriteSpool" command. "OpenWriteSpool" informs the client that it needs to set up the data transfer and be ready to write. Block 142 depicts reading the profile into the buffer. The CMM then makes a transfer call to the client, as shown in block 144. The transfer call is preferably a "WriteSpool" command. "WriteSpool" causes the client to check the size of the data stored in the buffer, read the data and send a return after all of the data has been read. A determination is then made in block 146 as to whether or not the entire profile is flattened. If the device profile is not flattened, the process returns to block 142. If the device profile is flattened, the process continues at block 148, with the CMM making a "CloseSpool" call to the client. "CloseSpool" informs the client that the flattening process is complete. The process then ends at block 118. FIG. 8 is a flowchart illustrating an alternative method to the method depicted in FIG. 7b for embedding a device profile into a document according to the present invention. The dispatcher calls a CMM by making a "CMFlattenProfile" call, as discussed earlier. The step is illustrated in block 150. The process then passes to block 152. Block 152 illustrates the determination of whether or not the CMM supports the function of flattening. If the CMM can not flatten the device profile, an error condition is returned to the dispatcher, as shown in block 154. The process then passes to block 156, which depicts the end of the process. If the CMM can flatten the device profile, the process continues at block 158. Block 158 depicts the allocation of scratch memory, preferably RAM, that will act as a data buffer during the flattening process. Next, a determination is made as to whether or not the buffer allocation is successful, as shown in block 160. If the buffer allocation failed because sufficient RAM is not available, the process passes to block 162, where a determination is made as to whether or not the amount of scratch memory is the minimum amount of memory that can be used as a data buffer. The minimum amount of memory is dependent on the total amount of scratch memory and how much is used up by other tasks. If the amount of scratch memory is less than the minimum, an error condition is returned, as shown in block 164. The process then ends at block 156. If the amount of scratch memory is not the minimum, the amount of memory requested is reduced, as illustrated in block 166. In the preferred embodiment, the amount of memory allocation is halved. The process then returns to block 160. If the buffer allocation is successful, the profile to be flattened is copied into a temporary file. This is accomplished by using the "CopyProfile" command. This step is illustrated in block 168. Next, the CMM sends a ready call to the client, as shown in block 170. In the preferred embodiment, the ready call is an "OpenWriteSpool" command. As discussed earlier, "OpenWriteSpool" informs the client that it needs to set up the data transfer and be ready to write. Block 172 depicts reading the profile into the buffer. The CMM then makes a transfer call to the client, as shown in block 174. The transfer call is preferably a "WriteSpool" command. "WriteSpool" causes the client to check the size of the data stored in the buffer, read the data and send a return after all of the data has been read. A determination is made in block 176 as to whether or not the entire profile is flattened. If the device profile is not flattened, the process returns to block 172. If the device profile is flattened, the process continues at block 178, with the CMM making a "CloseSpool" call to the client. "CloseSpool" informs the client that the flattening process is complete. The process then ends at block 156. FIGS. 9a-b are flowcharts illustrating a method for extracting a device profile from a document according to the present invention. The process of extracting, or reading out, an embedded device profile and reconstructing it as a disk-based device profile is called unflattening. Referring to FIG. 9a, the steps performed by the dispatcher (block 86 in FIG. 6) for unflattening a device profile are illustrated. The method begins at block 180 with a client requesting that a device profile be unflattened. The command preferably used by a client to request unflattening is given below.
______________________________________
pascal
CMError
UnflattenProfile(FSSpec *resultFileSpec, FlattenProcUPP proc,
void *refCon)
______________________________________
This command is discussed in greater detail in Appendix 2. The process then passes to block 182, where the dispatcher determines the preferred CMM. The dispatcher does this by sending an "OpenReadSpool" command followed by a "ReadSpool" command and reading the first 8 bytes to determine the preferred CMM. A determination is then made as to whether or not the preferred CMM is available, as shown in block 184. If the preferred CMM is not available, the process passes to block 186, where the Apple-supplied default CMM is called to unflatten the device profile. Additionally, an error condition is returned to the device driver or application indicating that the preferred CMM is not available. This step is depicted in block 188. The process then stops, as shown in block 190. Referring again to block 184, if the preferred CMM is available, the dispatcher calls that CMM. This step is shown in block 192. The dispatcher then checks the return code from the CMM to determine whether or not the preferred CMM can unflatten the device profile, as depicted in block 194. If the preferred CMM can not unflatten the device profile, the dispatcher calls the Apple-supplied default CMM to unflatten the profile, and an error condition is returned to the device driver or application software program indicating that the preferred CMM can not unflatten the device profile. These steps are illustrated in blocks 196 and 198, respectively. If the preferred CMM can unflatten the device profile, the profile is unflattened by that CMM, as illustrated in block 200. The process then ends at block 190. FIG. 9b depicts the steps performed by a CMM when called to unflatten a device profile, as illustrated in block 200 in FIG. 9a. In the preferred embodiment, the command used by the dispatcher to call a CMM is given below.
______________________________________
pascal
CMError
CMUnflattenProfile(ComponentInstance CMSession, Profile *prof,
FlattenUPP proc, void *refCon)
______________________________________
This command is discussed in greater detail in Appendix 2. The process begins at block 202, and thereafter passes to block 204. Block 204 illustrates the CMM's determination of whether or not it supports the function of unflattening. If the CMM can not unflatten the device profile, an error condition is returned, as shown in block 206. The process then ends at block 208. If the CMM can unflatten the device profile, the process continues at block 210, with the allocation of scratch memory, such as RAM, that will be a data buffer during unflattening of the device profile. Next, a determination is made as to whether or not the buffer allocation is successful, as shown in block 212. If the buffer allocation failed, the process passes to block 214, where a determination is made as to whether or not the amount of memory requested is the minimum amount of memory that can be allocated as a data buffer. If the amount of memory is the minimum, an error condition is returned, as shown in block 216. If the amount of memory is not the minimum, the requested amount of memory is reduced as illustrated in block 218. In the preferred embodiment, the amount of memory is halved. The process then returns to block 212. If the buffer allocation is successful, the CMM creates a file with a unique file name, as shown in block 220. This file will be used to store the profile when unflattened. The CMM then opens the file and makes an ready call, as depicted in blocks 222 and 224, respectively. The ready call alerts the client to set up the data transfer and be ready to send. In the preferred embodiment, the ready call is the "OpenReadSpool" command. Block 226 illustrates the next step, when the CMM makes a transfer call. This call is "ReadSpool" in the preferred embodiment, and causes the client to check the size of the data buffer and copy the embedded profile into the data buffer. The data is then written into the file by the CMM. The CMM determines whether or not the profile has been unflattened, as shown in block 228. If not, the process returns to block 226. If the profile has been unflattened, block 230 illustrates the next step, where the CMM makes a close call. In the preferred embodiment, the close call is "CloseSpool". The CMM then returns the newly created profile file specification to the client. The process then ends, as shown in block 208. One of the advantages of the preferred embodiment in the flatten and unflatten procedures is that the dispatcher always attempts to find and use the preferred CMM first. This provides at least two benefits. One, the preferred CMM is the CMM that will most likely be the one to perform color matching. It knows what profile elements are required to achieve high quality and high performance color transformations. Second, some of the custom profile elements may be too large to be embedded into the document. However, the CMM can store the larger elements in an external file or a network location and retrieve them when the profile is unflattened. In this manner, the custom or private data stored in a profile is not lost forever when the profile is flattened. While the invention has been particularly shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
|
Same subclass Same class Consider this |
||||||||||
