Re: Drawing an NSImage in a CALayer

2008-10-09 Thread Steven Degutis
Hi, I just came across this thread, and I solved a similar problem earlier. This is the code I ended up using: NSImage *oldImage; CALayer *layer; CGImageRef newImage = [[[oldImage representations] objectAtIndex:0] CGImage]; [layer setContents:(id)newImage]; It may be too late for this specific s

Re: Drawing an NSImage in a CALayer

2008-09-20 Thread Patrick Mau
Hi Matt I'm not involved in the discussion. I just wanted to thank you for the complete example, because I'm following this thread too. Regards, Patrick On 19.09.2008, at 19:48, Matt Long wrote: Hey Brad, I re-read my message and realized I was a bit condescending in my comments. Not su

Re: Drawing an NSImage in a CALayer

2008-09-19 Thread David Duncan
On Sep 19, 2008, at 10:48 AM, Matt Long wrote: p.s. I would defer to David Duncan on the CGImageRef creation overhead. I'm sure he's right. I just didn't have the time to try to get his code to work. ;-) I forgot to set the current context :). More complete code here, although this doesn

Re: Drawing an NSImage in a CALayer

2008-09-19 Thread Matt Long
Hey Brad, I re-read my message and realized I was a bit condescending in my comments. Not sure why I was over-stating things so much. I didn't think I was in a bad mood, but maybe I was. ;-) Anyhow, sorry about that. I'm interested in what you are doing here so I went ahead and wrote a

Re: Drawing an NSImage in a CALayer

2008-09-18 Thread David Duncan
On Sep 18, 2008, at 3:33 PM, Brad Gibbs wrote: The PNG is in the main bundle -- in my Resources folder. You can do this to get a CGImageRef directly. (written in Mail, no error checking). CFURLRef imageURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)@"myImage.png", NU

Re: Drawing an NSImage in a CALayer

2008-09-18 Thread Brad Gibbs
On Sep 18, 2008, at 3:18 PM, Matt Long wrote: You've got some fundamental issues here. That doesn't surprise me... This call in particular: imageLayer drawLayer:imageLayer inContext:ctx]; It doesn't make sense. -drawLayer:inContext is a delegate method. You are overriding drawing funct

Re: Drawing an NSImage in a CALayer

2008-09-18 Thread Brad Gibbs
The PNG is in the main bundle -- in my Resources folder. On Sep 18, 2008, at 3:16 PM, David Duncan wrote: On Sep 18, 2008, at 2:54 PM, Brad Gibbs wrote: I'm trying to draw an NSImage (a PNG) in a CALayer. The goal is to create a method that allows me to pass an NSImage as an argument to

Re: Drawing an NSImage in a CALayer

2008-09-18 Thread Matt Long
You've got some fundamental issues here. This call in particular: imageLayer drawLayer:imageLayer inContext:ctx]; It doesn't make sense. -drawLayer:inContext is a delegate method. You are overriding drawing functionality for the layer in question. Instead you would set the layer's delegate

Re: Drawing an NSImage in a CALayer

2008-09-18 Thread David Duncan
On Sep 18, 2008, at 2:54 PM, Brad Gibbs wrote: I'm trying to draw an NSImage (a PNG) in a CALayer. The goal is to create a method that allows me to pass an NSImage as an argument to create a layer-hosting view. I have: Where is this PNG originating? The answer may mean a simpler (and po

Drawing an NSImage in a CALayer

2008-09-18 Thread Brad Gibbs
Hi, I'm trying to draw an NSImage (a PNG) in a CALayer. The goal is to create a method that allows me to pass an NSImage as an argument to create a layer-hosting view. I have: -(id)drawButton: (NSView *)button withImage:(NSImage *)anImage { ... // image layer imageLayer=[CALayer