Re: Converting CGImageRefs to NSImages, how?
Re: Converting CGImageRefs to NSImages, how?
- Subject: Re: Converting CGImageRefs to NSImages, how?
- From: Ken Tozier <email@hidden>
- Date: Mon, 25 Apr 2005 21:59:07 -0400
Simple. Draw it using CG in a lock focus view. The NSGraphicsContext has a 'graphicsPort' that gives you the CGContextRef. (The CGRect coercion is to make the compiler happy even though CGRect has the same struct layout as NSRect)
NSImage* image = [[NSImage alloc] initWithSize:rect.size]; [image lockFocus]; CGContextDrawImage([[NSGraphicsContext currentContext] graphicsPort], *(CGRect*)&rect, imageRef); [image unlockFocus];
Very nice! Thanks Andrew. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden