Re: Business as usual: Flipped context causing grief
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