• 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: Setting NSImage with overlay blend to NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting NSImage with overlay blend to NSImageView


  • Subject: Re: Setting NSImage with overlay blend to NSImageView
  • From: Michael Vannorsdel <email@hidden>
  • Date: Wed, 23 Apr 2008 03:34:31 -0600

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 (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: 
 >Setting NSImage with overlay blend to NSImageView (From: Ross Oliver <email@hidden>)

  • Prev by Date: Re: Uneditable NSTableView
  • Next by Date: NSScanner question
  • Previous by thread: Setting NSImage with overlay blend to NSImageView
  • Next by thread: Uneditable NSTableView
  • Index(es):
    • Date
    • Thread