2009-05-05 48 views
1

我有现有的代码,它使用CMNewProfileSearch来查找,然后遍历系统上的颜色配置文件以获取它们的名称和完整路径。不幸的是,CMNewProfileSearch在Mac OS X 10.5中已弃用,并且在编译64位应用程序时也不可用。用未弃用的64位代码替换CMNewProfileSearch

在阅读ColorSync Manager 2.5 Reference时,似乎重复安装的颜色配置文件的新方法是使用CMIterateColorSyncFolder函数。

  1. 这是真的吗?
  2. 有没有可可的方式来做我想要的呢?
  3. 有人有任何示例代码?

谢谢。

回答

1
  1. 是的。如您所示,ColorSync Manager Reference指出以下内容:

    CMNewProfileSearch函数未充分利用从ColorSync版本2.5开始的优化配置文件 搜索。改为使用CMIterateColorSyncFolder 。

  2. CMIterateColorSyncFolder官方这样做的方法。此外,这也是优化的方式。

  3. Apple's ImageApp sample code

编辑:我已经修改了代码示例删除NewCMProfileIterateUPPDisposeCMProfileIterateUPP


    // Callback routine with a description of a profile that is 
    // called during an iteration through the available profiles. 
    // 
    static OSErr profileIterate (CMProfileIterateData *info, void *refCon) 
    { 
     NSMutableArray* array = (NSMutableArray*) refCon; 

     Profile* prof = [Profile profileWithIterateData:info]; 
     if (prof) 
      [array addObject:prof]; 

     return noErr; 
    } 

    // return an array of all profiles 
    // 
    + (NSArray*) arrayOfAllProfiles 
    { 
     NSMutableArray* profs=[[NSMutableArray arrayWithCapacity:0] retain]; 
     CMIterateColorSyncFolder(profileIterate, NULL, 0L, profs); 
     return (NSArray*)profs; 
    } 

事实证明,不需要NewCMProfileIterateUPPDisposeCMProfileIterateUPP所以他们没有被替换成任何东西,只要我可以告诉。相反,您可以使用与上面的profileIterate匹配的签名来定义回调函数。然后您可以直接将回调函数传递给CMIterateColorSyncFolder

我测试了我在Mac OS X 10.5上的ImageApp中的更改,它按预期工作。

+0

函数NewCMProfileIterateUPP()和DisposeCMProfileIterateUPP()在Mac OS X 10.5中不推荐使用。 – 2009-05-05 03:37:08