CIImage绘图EXC

编程入门 行业动态 更新时间:2024-10-25 11:23:19
本文介绍了CIImage绘图EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以,我有一个 CIImage ,我试图画在 NSView 的 -drawRect 方法。

这是我调用绘制图像的代码行:

[outputCoreImage drawInRect:[self bounds] fromRect:originalBounds operation:NSCompositeSourceOver fraction:1];

outputCoreImage originalBounds 和 [self bounds] 都是非 - nil 各自的期望值。在狮子(OS X 10.7),这工作正常,但是在山狮(OS X 10.8)我收到一个 EXC_BAD_ACCESS 在这一行。如果我向上堆栈,我发现打破的内部函数调用是 CGLGetPixelFormat 。

frame#0:0x00007fff99c3b26d OpenGL`CGLGetPixelFormat + 27 frame#1:0x00007fff8fa98978 CoreImage`- [CIOpenGLContextImpl createAccelContext] + 335 frame#2:0x00007fff8fa98d30 CoreImage`- [CIOpenGLContextImpl updateContext ] + 111 frame#3:0x00007fff8fa9a865 CoreImage`- [CIOpenGLContextImpl _lockfeContext] + 25 frame#4:0x00007fff8fa7e4ac CoreImage`- [CIContextImpl setObject:forKey:] + 120 frame#5: 0x00007fff8fa9881c CoreImage`- [CIOpenGLContextImpl setObject:forKey:] + 259 frame#6:0x00007fff90db93e3 libCGXCoreImage.A.dylib`cgxcoreimage_instance_render + 1477 frame#7:0x00007fff97074ac6 CoreGraphics`CGSCoreImageInstanceRender + 32 frame #8:0x00007fff947c89cc libRIP.A.dylib`ripc_AcquireCoreImage + 1344 frame#9:0x00007fff947b8a00 libRIP.A.dylib`ripc_DrawShading + 9680 frame#10:0x00007fff96cb2b2b CoreGraphics`CGContextDrawShading + 51 frame #11:0x00007fff8fa78237 CoreImage`- [CICGContextImpl render:] + 918 frame#12:0x00007fff8fa7d76a CoreImage`- [CIContext drawImage:inRect:fromRect:] + 1855 frame#13:0x00007fff9897b8f3 AppKit `- [ CIImage(NSAppKitAdditions)drawInRect:fromRect:operation:fraction:] + 243

我有僵尸,

其他OpenGL测试:所有开启的日志异常都没有返回任何有用的信息。 b

我添加了这个块:

CIImage * anImage = [[CIImage alloc] init]; [[[self window] contentView] lockFocus]; { [anImage drawInRect:[[self window] frame] fromRect:[[self window] frame] operation:NSCompositeSourceOver fraction:1]; } [[[window] contentView] unlockFocus]; $ -windowDidLoad 方法的

code> NSWindowController 。它运行没有问题。

我添加了这个块:

NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@cache.virtualtourist/14/684723-Red_Square_Moscow.jpg]]; CIImage * anImage = [[CIImage alloc] initWithData:data]; [self lockFocus]; { [anImage drawInRect:[self bounds] fromRect:[anImage extent] operation:NSCompositeSourceOver fraction:1]; } [self unlockFocus];

到另一个 NSView 的 -drawRect 。我在 CGLGetPixelFormat 上收到了相同的错误。

雷达: b $ b

#macdev上的人似乎相信这是一个操作系统问题,我不倾向于不同意。我已提交了一个雷达(rdar:// 11980704)解释问题并链接回此问题。

解决方法: >

CGContextRef contextReference = [[NSGraphicsContext currentContext] graphicsPort]; CIContext * coreImageContext = [CIContext contextWithCGContext:contextReference options:@ {kCIContextUseSoftwareRenderer:@YES}]; [coreImageContext drawImage:outputCoreImage inRect:[self bounds] fromRect:originalBounds];

看起来像强制图像使用软件渲染器解决问题绘制。

解决方案

在10.8.1中已解决

#macdev上的人似乎相信这是一个操作系统问题,我不倾向于不同意。我提交了一个雷达(rdar:// 11980704)解释这个问题,并链接回这个问题。

So, I have a CIImage that I'm attempting to draw in an NSView's -drawRect method.

This is the line of code that I call to draw the image:

[outputCoreImage drawInRect: [self bounds] fromRect: originalBounds operation: NSCompositeSourceOver fraction: 1];

outputCoreImage, originalBounds, and [self bounds] are all non-nil, and indeed are their respective expected values. On Lion (OS X 10.7), this worked fine, however on Mountain Lion (OS X 10.8) I receive an EXC_BAD_ACCESS on this line. If I walk up the stack, I find that the internal function call that breaks is on CGLGetPixelFormat.

frame #0: 0x00007fff99c3b26d OpenGL`CGLGetPixelFormat + 27 frame #1: 0x00007fff8fa98978 CoreImage`-[CIOpenGLContextImpl createAccelContext] + 335 frame #2: 0x00007fff8fa98d30 CoreImage`-[CIOpenGLContextImpl updateContext] + 111 frame #3: 0x00007fff8fa9a865 CoreImage`-[CIOpenGLContextImpl _lockfeContext] + 25 frame #4: 0x00007fff8fa7e4ac CoreImage`-[CIContextImpl setObject:forKey:] + 120 frame #5: 0x00007fff8fa9881c CoreImage`-[CIOpenGLContextImpl setObject:forKey:] + 259 frame #6: 0x00007fff90db93e3 libCGXCoreImage.A.dylib`cgxcoreimage_instance_render + 1477 frame #7: 0x00007fff97074ac6 CoreGraphics`CGSCoreImageInstanceRender + 32 frame #8: 0x00007fff947c89cc libRIP.A.dylib`ripc_AcquireCoreImage + 1344 frame #9: 0x00007fff947b8a00 libRIP.A.dylib`ripc_DrawShading + 9680 frame #10: 0x00007fff96cb2b2b CoreGraphics`CGContextDrawShading + 51 frame #11: 0x00007fff8fa78237 CoreImage`-[CICGContextImpl render:] + 918 frame #12: 0x00007fff8fa7d76a CoreImage`-[CIContext drawImage:inRect:fromRect:] + 1855 frame #13: 0x00007fff9897b8f3 AppKit`-[CIImage(NSAppKitAdditions) drawInRect:fromRect:operation:fraction:] + 243

I have zombies, guard malloc, and log exceptions all turned on, and none of them return any useful information.

Other OpenGL Testing:

I added this chunk:

CIImage *anImage = [[CIImage alloc] init]; [[[self window] contentView] lockFocus]; { [anImage drawInRect: [[self window] frame] fromRect: [[self window] frame] operation: NSCompositeSourceOver fraction: 1]; } [[[self window] contentView] unlockFocus];

to the -windowDidLoad method of my NSWindowController. It runs without issue.

I added this chunk:

NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString: @"cache.virtualtourist/14/684723-Red_Square_Moscow.jpg"]]; CIImage *anImage = [[CIImage alloc] initWithData: data]; [self lockFocus]; { [anImage drawInRect: [self bounds] fromRect: [anImage extent] operation: NSCompositeSourceOver fraction: 1]; } [self unlockFocus];

to another NSView's -drawRect. I received the same error on CGLGetPixelFormat.

Radar:

The folks over at #macdev seem to believe that this is in an OS issue, and I'm not inclined to disagree. I've filed a radar (rdar://11980704) explaining the problem and linking back to this question.

Workaround:

CGContextRef contextReference = [[NSGraphicsContext currentContext] graphicsPort]; CIContext *coreImageContext = [CIContext contextWithCGContext: contextReference options: @{kCIContextUseSoftwareRenderer : @YES}]; [coreImageContext drawImage: outputCoreImage inRect: [self bounds] fromRect: originalBounds];

It looks like forcing the image to draw using the software renderer "solves" the problem. It's a bit blurry and slow, but it doesn't crash.

解决方案

Resolved in 10.8.1

The folks over at #macdev seem to believe that this is in an OS issue, and I'm not inclined to disagree. I've filed a radar (rdar://11980704) explaining the problem and linking back to this question.

更多推荐

CIImage绘图EXC

本文发布于:2023-11-26 12:44:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CIImage   EXC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!