Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

image conversion, a better way to CGImageRef



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.