-[CALayer setContents: cvPixelBufferRef ] ?
-[CALayer setContents: cvPixelBufferRef ] ?
- Subject: -[CALayer setContents: cvPixelBufferRef ] ?
- From: "Jonathan del Strother" <email@hidden>
- Date: Thu, 3 Apr 2008 19:34:29 +0100
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 (email@hidden)
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:
This email sent to email@hidden