• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convert GWorldPtr into a NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Convert GWorldPtr into a NSImage
      • From: Daniel Kennett <email@hidden>
    • Re: Convert GWorldPtr into a NSImage
      • From: Eric Gorr <email@hidden>
References: 
 >Convert GWorldPtr into a NSImage (From: Eric Gorr <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Graham Cox <email@hidden>)
 >Re: Convert GWorldPtr into a NSImage (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: feed an NSCharacterSet to numberOfRowsInSection delegate method?
  • Next by Date: Re: Works in main Thread, but not in background Thread (modified)
  • Previous by thread: Re: Convert GWorldPtr into a NSImage
  • Next by thread: Re: Convert GWorldPtr into a NSImage
  • Index(es):
    • Date
    • Thread