I am new to this list (and Quartz) and I hope my question in on-topic.
Are there any convenience methods to convert between Cocoa and Quartz
images? I've looked and have found that:
1) they don't seem to be 'toll free bridged'
NSImage "lives" at a much higher level than CGImage. NSImage
implements a number of image cacheing schemes, can handle multiple
representations of the same image, and much, much more. CGImage, in
contrast, is a relatively simple class for handling sampled images. It
really wouldn't make much sense for the two to be toll-free bridged.
They "live in two different worlds".
2) WebKit provides NSImage to CGImageRef conversion
In my specific case, I'm looking to convert an NSBitmapImageRep to a
'bitmap graphics context', and vice versa, though I'm curious about
conversions in general. (I know I could use CGBitmapContextCreate()
-bitmapData, but I'm hoping for a one-liner :) )
I don't know of a one-liner. You say you want a "bitmap graphics
context" which implies that you want to draw on the image. If that's
the case then you could put the NSBitmapImageRep into an NSImage and
use the lockFocus/unlockFocus mechanism to get a drawing context on the
If you want to create a CGBitmapImageContext on the same memory area as
the NSBitmapImageRep, you could probably do that using
CGBitmapContextCreate and the methods of NSBitmapImageRep. However, I
couldn't recommend that because I suspect that the memory buffers of an
NSImage, like the buffers of a CGImage, are probably supposed to be
immutable outside of a lockFocus/unlockFocus type environment.
What exactly are you trying to do with the images?
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden