【问题标题】:BSXPCMessage Error on CIContext & Performance in iOS8iOS8 中 CIContext 和性能上的 BSXPCMessage 错误
【发布时间】:2015-04-09 12:51:21
【问题描述】:

每当我为要允许用户编辑的图像创建CIContext 时,都会出现此错误BSXPCMessage received error for message: Connection interrupted。这个错误可以在像这样的其他 stackoverflow 问题上找到 - BSXPCMessage received error for message: Connection interrupted on CIContext with iOS 8

然而,虽然接受的答案 (https://stackoverflow.com/a/26268910/2939977) 确实可以消除错误消息,但它会使 CPU 使用率飙升到无法使用的水平,并使 UI 变得非常不稳定(一旦@987654327,CPU 使用率从 50% 上升到大约 150% @ 标志设置为 YES),因为我的过滤器附加到滑块并且性能至关重要。

我尝试按照apple documentation here 创建一个EAGL context 来创建我将颜色空间设置为null 的CIContext。

EAGLContext *myEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
NSDictionary *options = @{ kCIContextWorkingColorSpace : [NSNull null] };
imageContext = [CIContext contextWithEAGLContext:myEAGLContext options:options];

这会创建没有错误消息的过滤器,并且性能要好得多万岁!但是,一旦用户使用编辑选项来调整图像,我就会在第一次调整时得到BSXPCMessage received error for message: Connection interrupted。我再也没有看到错误消息,它似乎根本不影响输出。

[filter setValue:@(contrast) forKey:@"inputContrast"];
[filter setValue:@(color) forKey:@"inputSaturation"];

CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [imageContext createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImage = [UIImage imageWithCGImage:cgimg scale:1 orientation:UIImageOrientationRight];
transitionImage.image = newImage;
CGImageRelease(cgimg);

如果您想知道我确实从 GPUImage 开始,因为在滑块上使用过滤器时性能更好,但发现它在图像缩放方面存在一些其他问题,导致我将其删除并向下移动 @987654335 @路线。

任何建议或帮助将不胜感激:)

【问题讨论】:

标签: objective-c core-image


【解决方案1】:

如果你要创建一个 CIContext:

[CIContext contextWithEAGLContext:options:] 

那么您应该使用以下方法直接绘制到该上下文中:

[cictx drawImage:inRect:fromRect:]

这将比创建 CGImageRef 并将其传递给 UIImageView 快得多。

【讨论】:

  • 感谢大卫的提示......当他们使用滑块时,获取 CIContext 并将其显示给用户(当前正在查看 UIImage)的最佳方式是什么?似乎大多数事情都是通过 CGImage 将其推送到 UIImage 中。有没有更有效的方法?
猜你喜欢
  • 1970-01-01
  • 2014-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-24
  • 1970-01-01
相关资源
最近更新 更多