Re: Convert GWorldPtr into a NSImage
Re: Convert GWorldPtr into a NSImage
- Subject: Re: Convert GWorldPtr into a NSImage
- From: Graham Cox <email@hidden>
- Date: Fri, 9 Jan 2009 10:00:03 +1100
On 9 Jan 2009, at 12:53 am, Eric Gorr wrote:
Interesting. It looks like the function has a pixelFormatType
parameter, so there is no need to place it in the attributes
dictionary. While it does look like I could get a CVPixelBufferRef,
what is unclear is how I could get a NSImage from the
CVPixelBufferRef. I've searched briefly, but couldn't come up with
anything...all of the messages I found mentioning both these items
talk about converting a NSImage to a CVPixelBufferRef.
Once you have a raw pixel buffer of any sort, it's easy to get it into
an NSImage.
First wrap a NSBitmapImageRep around it - you can pass in the base
address of the pixel buffer in the first parameter ("planes").
Then add the rep to an NSImage. At no point is it necessary to create
a context, data provider, do any drawing or anything else - you have
the data (the pixel buffer) it just needs putting into the right
structure.
--Graham
_______________________________________________
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