Re: drawing an image in an NSRect?
Re: drawing an image in an NSRect?
- Subject: Re: drawing an image in an NSRect?
- From: p3consulting <email@hidden>
- Date: Tue, 2 Mar 2004 12:37:02 +0100
On 2 mars 2004, at 02:31, Iain Wood wrote:
On 1 Mar 2004, at 21:24, p3consulting wrote:
@implementation DarkSliderCell
-(void)drawKnob:(NSRect)knobRect
{
//[[NSColor blueColor] set];
//[NSBezierPath fillRect:knobRect];
knobImage=[[NSImage alloc]
initWithContentsOfFile:@"/Users/ndiw/prog/Nova/darkKnob.jpg"];
[knobImage setSize:knobRect.size];
[knobImage compositeToPoint:NSZeroPoint
operation:NSCompositeSourceOver];
Have you tried
[knobImage compositeToPoint: knobRect.origin
operation:NSCompositeSourceOver];
Thanks, that gave me the clue I was needing. I had to modify it
slighly to get the image in the right place ie:
[knobImage
compositeToPoint:
NSMakePoint(knobRect.origin.x,knobRect.origin.y+knobRect.size.height)
operation:NSCompositeSourceOver];
(you should cache the image...)
I was going to try creating the NSImage in an init method. Is that
what you mean?
init is a good place to do it indeed,
and what I mean is:
avoid memory allocation and disk access in a drawing routine that is
called so often
that doesn't help performance.
also the path should not be absolute but relative to your application
bundle
(put the image in the Resources of your app, see NSBundle doc)
Pascal Pochet
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.