是否可以使用我的应用程序分发图像单元?

时间:2011-09-22 21:03:28

标签: macos cocoa quartz-graphics

Mac OS X Mavericks

我被告知此问题已在Mac OS X 10.9中修复

原始

我阅读了文档并没有找到答案。它建议创建图像单元,它需要将此单元放在~/Library/Graphics/Image Units或/ Library/Graphics/Image Units内(将图像单元置于Your.app/Contents/Library/Graphics/Image Units内无效)。

还有其他非推荐的方法来创建Image Unit,它允许您分发cikernel并从代码中访问过滤器。但它阻止您创建非可执行的过滤器,这是一个很大的性能缺失。

我浏览了Pixelmator或Acorn等应用程序包的内容,发现他们也没有使用Image Units。我希望这是一个错误,并且有一种方法可以在应用程序包中分发图像单元。

我正在寻找一种可以被Mac App Store验证接受的解决方案。

不允许您使用非可执行过滤器的解决方案

从CIPlugIn标题: / **加载由其URL指定的插件。 * /

+ (void)loadPlugIn:(NSURL *)url allowNonExecutable:(BOOL)allowNonExecutable
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7;

/** Loads a plug-in specified by its URL.

 If allowExecutableCode is NO, filters containing executable code will not be loaded. If YES, any kind of filter will be loaded. */
+ (void)loadPlugIn:(NSURL *)url allowExecutableCode:(BOOL)allowExecutableCode
AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER;

新方法未在官方文档中列出。因此,要加载包,您只需执行以下操作:

if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_6)
{
    [CIPlugIn loadPlugIn:[[NSBundle mainBundle] URLForResource:@"YourPlugin" withExtension:@"plugin"]
      allowNonExecutable:YES];
}
else
{
    [CIPlugIn loadPlugIn:[[NSBundle mainBundle] URLForResource:@"YourPlugin" withExtension:@"plugin"]
     allowExecutableCode:YES];
}

不幸的是,如果您尝试将CIFilter与QuartzCore框架一起使用(例如使用CALayer),应用程序将因堆栈溢出而崩溃。

frame #0: 0x00007fff8b6a5d36 CoreImage`-[CIFilter copyWithZone:] + 12
frame #1: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #2: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47
frame #3: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #4: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47
frame #5: 0x00007fff8b7d1c7e CoreImage`-[CIPlugInStandardFilter _provideFilterCopyWithZone:] + 18
frame #6: 0x00007fff8b6a5d59 CoreImage`-[CIFilter copyWithZone:] + 47

1 个答案:

答案 0 :(得分:2)

除了你提到的图书馆路径,Mac OS X还会查看YourApp.app/Contents/Library

如果您将图像单元放在YourApp.app/Contents/Library/Graphics/Image Units/中,我认为一切都会有效。

相关问题