I have a CVPixelBufferRef, with a 2vuy pixel format. I'd like to display it in a CALayer.
CALayer says that 'contents' is "typically a CGImageRef, but may be something else". I (optimistically) tried assigning the CVPixelBufferRef directly to the contents, but apparently that's not included in the mysterious 'something else' list. The only way I've found of going from CVPixelBufferRef to CGImageRef is via CIImage, something like the following : CVImageBufferRef cvImage = some_2vuy_CVPixelBufferRef_image_source; CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort]; CIContext* drawingContext = [CIContext contextWithCGContext:cgContext options:nil]; CIImage* ciImage = [CIImage imageWithCVImageBuffer:cvImage]; CGImageRef cgImage = [drawingContext createCGImage:ciImage fromRect:CVImageBufferGetCleanRect(cvImage)]; - which kinda works, but seems slow (and somewhere along the line, I'm leaking memory like crazy. Memory that doesn't show up in MallocDebug, which is odd...) The fastest way I've got so far is to create a Quartz Composition with an Image input port, create a QCCompositionLayer, and assign the CVPixelBufferRef directly to the input port. That seems somewhat contorted - is there a more obvious way? Cheers, Jon _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]