【问题标题】:Is it possible to distribute Image Units with my application?是否可以通过我的应用程序分发图像单元?
【发布时间】:2011-09-22 21:03:28
【问题描述】:

Mac OS X Mavericks

有人告诉我该问题已在 Mac OS X 10.9 中修复

原创

我阅读了文档但没有找到答案。建议创建Image Units,需要把这个单元放在~/Library/Graphics/Image Units或者/Library/Graphics/Image Units里面(把图片单元放在Your.app/Contents/Library/Graphics/Image Units里面没有效果)。

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

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

我正在寻找一种能够被 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

【问题讨论】:

  • 你在应用程序启动时打电话给[CIPlugin loadAllPlugIns]吗?

标签: macos cocoa quartz-graphics


【解决方案1】:

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

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

【讨论】:

  • 对不起,应用程序包中的路径拼写错误。不行,我已经试过了。
  • 这很烦人,我绝对认为您应该将其作为错误报告给 Apple。您的应用是否可以提供指向您网站的链接,以便用户可以手动下载和安装捆绑包?我意识到这远非理想。
  • 是的,然后我会提交一个错误。我假设我应该设置一种 plist 选项来告诉系统在哪里寻找图像单元。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-04
相关资源
最近更新 更多