Each view draw's into the window's graphic context. When focus is locked on a view the window's context is clipped and translated to the view so that drawing is limited to just the view's bounds. Basically all views in a window generally use the window's context (OpenGL views and whatnot have their own context). To get the context for the window use NSGraphicsContext's graphicsContextWithWindow: or NSWindow's graphicsContext to get the Cocoa context, then use the graphicsPort method to get a CGContextRef from it (docs say it returns a void*, but it is a CGContextRef).

Also, I believe a window has a different graphics context for each thread that draws to it, so try and draw from the thread you got the CGContextRef from. Probably just keep drawing within the main thread to be safe.

You might also look into CoreImage (CIImage, CIContext) if you need to support 10.4; many of the new CGContext blend modes are 10.5 only.


On Apr 23, 2008, at 1:13 AM, Ross Oliver wrote:

I haven't used core graphics before and I'm looking to create an overlay blend mode effect with two images.

I have a NSImageView with the image set to an NSImage. What are the general steps I would need to take to draw another image on top of it and set it as an overlay?

The documentation Apple has is long and confusing - I can't seem to figure out how to even get a CGContextRef for the NSImageView.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to