Important: The information in this document is obsolete and should not be used for new development.
Searching for Profiles in the ColorSync(TM) Profiles Folder
Your application can use the ColorSync Manager search functions to obtain a list identifying profiles in the ColorSync(TM) Profiles folder that meet specifications you supply in a search record. For example, you can use these functions to find all profiles for printers that meet certain criteria defined in the profile. Your application can walk through the result listing that identifies these profiles and obtain the name and script code of each profile corresponding to a specific index in the list. Your application can then display a selection menu showing the names of the profiles to your user. Listing 4-11 shows sample code that takes an approach similar to one this example describes.
The MyProfileSearch function, shown in Listing 4-11, defines values for the search specification record fields, including the search mask, and assigns those values to the record's fields after initializing the search result. Then MyProfileSearch calls the CMNewProfileSearch function to search the ColorSync(TM) Profiles folder for profiles that meet the search specification requirements. The CMNewProfileSearch function returns a one-based count of the profiles matching the search specification and a reference to the search result list of the matching profiles.
- Note
- You can also search the ColorSync(TM) Profiles folder for profiles that match a profile identifier. For more information, see "Searching for a Profile That Matches a Profile Identifier" (page 4-75), and the
CMProfileIdentifierFolderSearch
function in Advanced Color Imaging Reference.Next, the MyProfileSearch function calls the
CMSearchGetIndProfile
function to obtain a reference to a specific profile corresponding to a specific index in the search result list. Passing the profile reference returned by theCMSearchGetIndProfile
function as thefoundProf
parameter, MyProfileSearch calls theCMGetScriptProfileDescription
function to obtain the profile name and script code.Finally, the MyProfileSearch function cleans up, calling the
CMCloseProfile
function to close the profile and theCMDisposeProfileSearch
function to dispose of the search result list.Listing 4-11 Searching for specific profiles in the ColorSync(TM) Profiles folder
#define kSearchMask(cmMatchProfileCMMType + cmMatchProfileClass + cmMatchAttributes) void MyProfileSearch (void) { CMError cmErr; CMProfileRef foundProf; Str255 profName; ScriptCode profScript; CMSearchRecord searchSpec; CMProfileSearchRefsearchResult; unsigned long searchCount; unsigned long i; /* init for error handling */ searchResult = NULL; /* specify search for Apple default CMM printer profiles for transparent media */ searchSpec.CMMType = kDefaultCMMSignature;/* profile uses default CMM */ searchSpec.profileClass = cmOutputClass;/* printer profiles */ searchSpec.deviceAttributes[0]= 0x00000000;/* no deviceAttributes[0] bits set */ searchSpec.deviceAttributes[1] = cmReflectiveTransparentMask; /* transparent media */ searchSpec.searchMask = kSearchMask; searchSpec.filter= NULL; /* filter proc is not used */ cmErr = CMNewProfileSearch(&searchSpec, NULL, &searchCount, &searchResult); if (cmErr == noErr) { for (i = 1; i <= searchCount; i++) { if (CMSearchGetIndProfile(searchResult, i, &foundProf) != noErr) { break; } cmErr = CMGetScriptProfileDescription(foundProf, profName, &profScript); if (cmErr == noErr) { /* assume profile name ScriptCode is smRoman */ (void) printf("%s\n", p2cstr(profName)); } (void) CMCloseProfile(foundProf); } } if (searchResult != NULL) { CMDisposeProfileSearch(searchResult); } }