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: Thu, 8 Jan 2009 02:24:48 +1100
On 8 Jan 2009, at 1:56 am, Eric Gorr wrote:
So, it is likely a problem that the pixelFormat (according to the
debugger) for the GWorldPtr is BGRA...?
The reason it looks like this is likely because of non-native byte
ordering. You need to deal with that.
NSBitmapImageRep *bitmap_rep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
<---------------
You could just pass the pixMap base address in right here. Your code
looks awfully complicated for what should be a straightforward job of
wrapping the new structure (NSBitMapImageRep) around an existing pixel
buffer.
However if you need to flip each pixel's byte order you might not have
much choice but to iterate over the buffer and do it by hand. It's
still going to be much simpler than creating a data provider, etc.
You've already got the data, all that other stuff looks like overkill.
You don't say what you're trying to do
I am trying to convert a GWorldPtr to a NSImage.
Very informative. What I meant was, where has the GWorld come from and
what do you want to do with it? It's not an idle question - if you
just have an occasional need to convert then that might suggest one
solution, but if you are trying to go at video rates you'll need
another.
hth,
--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