ADC Home > Reference Library > Technical Q&As > Graphics & Imaging > ColorSync >

Getting the name of a profile


Q: I'd like to programmatically get the name of a ColorSync profile. How is this done?

A: Traditionally, a single localization of the profile name is stored in the 'desc' tag containing data with the signature 'desc'. For some ICC version 4 and version 2 profiles, multiple localized names for the profile are stored in the 'desc' or 'dscm' tag containing data with the signature 'mluc'. You can use the CMCopyProfileLocalizedString or CMCopyProfileLocalizedStringDictionary functions provided by ColorSync for accessing the new 'mluc' Multi-localized UniCode Tag (refer to TN 2035 ColorSync On Mac OS X for additional information).

The best method to get the name is to:

a) First call CMCopyProfileLocalizedString to get the best localized name from the 'desc'/'mluc' tag (if present).

b) If this fails, call CMCopyProfileLocalizedString to get the best localized name from the 'dscm'/'mluc' tag (if present).

c) If both of the above fail, call CMGetScriptProfileDescription to get the name from the traditional 'desc' tag.

The code snippet in Listing 1 below shows how to use the above mentioned functions to get the profile name. This code finds the name and returns it as a CFString:

 CFStringRef CopyProfileDescriptionCFString(CMProfileRef prof)
{
    Str255         pName;
    ScriptCode     code;
    CFStringRef    str = nil;
    CMError        err;


    // for v4 profiles, try to get the best localized name from the 'desc'/'mluc' tag
    err = CMCopyProfileLocalizedString(prof, cmProfileDescriptionTag, 0,0, &str);
    // if that didn't work...
    if (err != noErr)
    {
        // for Apple's localized v2 profiles, try to get the best localized name from the 'dscm'/'mluc' tag
        err = CMCopyProfileLocalizedString(prof, cmProfileDescriptionMLTag, 0,0, &str);
        // if that didn't work...
        if (err != noErr)
        {
            // for normal v2 profiles, get the name from the 'desc'/'desc' tag
            err = CMGetScriptProfileDescription( prof, pName, &code);
            // convert it to a CFString
            if (err == noErr)
            {
                str = CFStringCreateWithPascalString(0, pName, code);
            }
        }
    }
    return str;
}

Listing 1. Getting the name of a ColorSync profile



[Oct 25 2002]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.