image conversion, a better way to CGImageRef
image conversion, a better way to CGImageRef
- Subject: image conversion, a better way to CGImageRef
- From: John Clayton <email@hidden>
- Date: Fri, 30 Nov 2007 00:57:20 +0100
Hello List :-)
I'm curious to know if there is a fast way to convert a QT visual
context based frame into a CGImageRef.
Presently I think I'm doing it in a rather expensive way, namely:
CVImageBufferRef imageBuffer = 0;
QTVisualContextCopyImageForTime(_textureContext,
kCFAllocatorDefault,
0,
&imageBuffer);
CGImageRef _imageRef = 0;
float w = self.frame.size.width;
float h = self.frame.size.height;
NSRect rect = NSMakeRect(0, 0, w, h);
CIImage* theImage = [CIImage imageWithCVImageBuffer:imageBuffer];
CGSize cgTexSize = CVImageBufferGetDisplaySize(imageBuffer);
rect = rectAdjustedToAspectRatio(NSMakeRect(0, 0, w, h),
NSMakeSize(cgTexSize.width, cgTexSize.height));
CGRect theImageRect = CGRectMake(rect.origin.x, rect.origin.y,
rect.size.width, rect.size.height);
// this bit is pretty expensive I believe...
[_ciContext drawImage: theImage inRect: theImageRect fromRect:
[theImage extent]];
_imageRef = [_ciContext createCGImage:theImage fromRect:theImageRect];
The CIContext (_ciContext) was initialised using a glContext and
pixelFormat from within prepareOpenGL of an NSOpenGLView.
Does anyone know of a faster way to obtain a CGImageRef from the QT
visual context? Thanks in advance, have a good day.
--
John Clayton
http://www.coderage-software.com/
_______________________________________________
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