I'm having problems drawing the NSCIImageRep that I get through QTKit mCaptureDecompressedVideoOutput.
Since I don't want to draw an image using OpenGL, I tried to subclass NSView and draw the image there:
- (void) drawRect:(NSRect)dirtyRect { NSLog(@"DrawInRect"); CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort]; if (imageRep != nil) { CGImageRef image = [imageRep CGImageForProposedRect: &dirtyRect context: [NSGraphicsContext currentContext] hints:nil]; CGContextDrawImage(myContext, dirtyRect, image); CGImageRelease(image); } }
imageRep is a pointer to a CGImageRef that I get through the mCaptureDecompressedVideoOutput callback
- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection`.
This code crashes my car. Any suggestions?
source share