Re: Problem adding a background NSImageView in a Cocoa View
Re: Problem adding a background NSImageView in a Cocoa View
- Subject: Re: Problem adding a background NSImageView in a Cocoa View
- From: "tahome izwah" <email@hidden>
- Date: Fri, 30 Nov 2007 08:46:44 +0100
Hi again Jorge,
just a quick supplemental comment to what I said earlier today: since
this is a Cocoa view AU I need to get the image from the bundle first,
ie. do something like this:
NSBundle* bundle = [NSBundle
bundleWithIdentifier:@"com.apple.demo.audiounit.WaveformViewDemo"];
NSImage *anImage = [[NSImage alloc] initWithContentsOfFile:[bundle
pathForResource:@"128" ofType:@"png"]];
Best
--th
2007/11/30, Jorge Castellanos <email@hidden>:
>
> b) The code you wrote below works, but there is an easier and shorter
> way to do it using Cocoa. In drawRect stick the following code:
>
> // Load the image.
> NSImage *anImage = [NSImage imageNamed:@"imageName"];
>
> // Find the point at which to draw it.
> NSPoint backgroundCenter;
> backgroundCenter.x = [self bounds].size.width * 0.5;
> backgroundCenter.y = [self bounds].size.height * 0.5;
>
> NSPoint drawPoint = backgroundCenter;
> drawPoint.x -= [anImage size].width * 0.5;
> drawPoint.y -= [anImage size].height * 0.5;
>
> // Draw it.
> [anImage drawAtPoint:drawPoint fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:1.0];
>
>
> Hope this helps!
>
> jorge castellanos
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden