macos - 是否可以通过我的应用程序分发图像单元?

标签 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 内无效)。

还有其他不推荐的方法来创建图像单元,它允许您分发 cikernels 并从代码中访问过滤器。但它会阻止您创建不可执行的过滤器,这会严重降低性能。

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

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

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

来自 CIPlugIn header : /** 加载由其 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;

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

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

最佳答案

除了您提到的库路径之外,Mac OS X 还会在 YourApp.app/Contents/Library 中查找。

我认为,如果您将图像单元放入 YourApp.app/Contents/Library/Graphics/Image Units/ 中,一切都应该正常。

关于macos - 是否可以通过我的应用程序分发图像单元?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7521496/

相关文章:

r - 错误: vector memory exhausted (limit reached?)

java - IntelliJ IDEA 14.1 缓慢启动 Tomcat 7 EE Web 应用程序

cocoa - 更改文件保存位置

iPhone - 编码和解码 NSValue

c++ - 变量的类型不完整 'ParamBlockRec'(又名 'ParamBlockRec')

cocoa - 为 Cocoa 应用程序分配图标——可以使用 SVG 吗?

macos - NSTextField 单击的链接颜色

iphone - "Bundle identifier"的重要性

cocoa - 如何唯一标识cgcontext?

ios - 动画 Quartz 2d