• 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: Business as usual: Flipped context causing grief
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Business as usual: Flipped context causing grief


  • Subject: Re: Business as usual: Flipped context causing grief
  • From: Graham Cox <email@hidden>
  • Date: Tue, 13 Dec 2011 12:32:30 +1100

OK, that works, I get the desired result. Thanks - that confirms my understanding about the flippedness of the context and so on, which is good.

So I have a question now about efficiency. I create a NSBitmapImageRep, and I let it allocate the buffer memory. In order to create a GCBitmapContext using the same memory, I pass the result of -[NSBitmapImageRep bitmapData] to CGBitmapContextCreate(). I can then pass this context as suggested to +[NSGraphicsContext graphicsContextWithGraphicsPort:flipped:]

When I get the bitmapData from the rep, is that the same block of memory it allocated, or is it a copy? I seem to recall a discussion that this could allocate memory in video RAM and hence will return a copy if forced to by asking for the bytes. If it does do that, it probably doesn't matter (and it works) but ideally it would be nice to avoid any such copy if possible.

To put it another way: what is the most efficient and straightforward way to turn a NSBitmapImageRep into a CGBitmapContextRef?


--Graham





On 13/12/2011, at 12:19 PM, Aki Inoue wrote:

> Graham,
>
> +[NSGraphicsContext graphicsContextWithBitmapImageRep:] is a cover method of a more general, +[NSGraphicsContext graphicsContextWithGraphicsPort:flipped:].
>
> You can create a CGBitmapContextRef out of the bitmap rep & pass to the latter method.
>
> Aki



_______________________________________________

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

References: 
 >Business as usual: Flipped context causing grief (From: Graham Cox <email@hidden>)
 >Re: Business as usual: Flipped context causing grief (From: Keary Suska <email@hidden>)
 >Re: Business as usual: Flipped context causing grief (From: Graham Cox <email@hidden>)
 >Re: Business as usual: Flipped context causing grief (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: Business as usual: Flipped context causing grief
  • Next by Date: Our app can't store a simple key/value pair in iCloud. Any idea why?
  • Previous by thread: Re: Business as usual: Flipped context causing grief
  • Next by thread: Our app can't store a simple key/value pair in iCloud. Any idea why?
  • Index(es):
    • Date
    • Thread