• 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
Fwd: background image in cocoa view AU
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: background image in cocoa view AU


  • Subject: Fwd: background image in cocoa view AU
  • From: Nicolas Dangy-Caye <email@hidden>
  • Date: Wed, 19 Jan 2005 12:37:01 +0100

I've modified the code inside awakeFromNib into :

- (void)awakeFromNib {
NSBundle *resource = [NSBundle bundleForClass:[self class]];
NSString *backgroundPath = [resource pathForResource: @"background" ofType: @"png"];
NSImage *background = [[NSImage alloc] initWithContentsOfFile:backgroundPath];
mBackgroundColor = [NSColor colorWithPatternImage:background];
[mBackgroundColor retain];
}

It now works fine.
Thank you Mark for your time.
Nicolas.

Début du message réexpédié :

De: "Mark's Studio" <email@hidden>
Date: 19 janvier 2005 10:59:32 GMT+01:00
À: Nicolas Dangy-Caye <email@hidden>
Objet: Rép : background image in cocoa view AU

If the Cocoa UI is inside the AU bundle you have to do this to get the image.

NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com. PM.audiounit.spectrum"];
scale1 = [[NSImage alloc] initWithContentsOfFile:[bundle pathForImageResource:@"Scale1"]];

On 19/1-2005, at 10:25, Nicolas Dangy-Caye wrote:

Hi,

I'm trying to "convert" a VST plugin I wrote into an Audio Unit.
I'm new to Audio Unit (and also Obj-C and Cocoa !!!), so please be indulgent with my dummy questions...

I use the AudioUnit with CocoaView template and I want to add a background image into the view.
I added a background.png into the NIB file thanks to IB and add this code :

@interface
CocoaView : NSView
{
...
NSColor * mBackgroundColor;
...
}

- (void)awakeFromNib {
NSImage *background = [NSImage imageNamed:@"background"];
mBackgroundColor = [NSColor colorWithPatternImage:background];
[mBackgroundColor retain];
}

- (void)drawRect:(NSRect)rect {
[mBackgroundColor set];
[NSBezierPath fillRect:rect];
}

The result is a black background...
The problem seems to come from the NSImage background initialisation, the pointer stays nil after the [NSImage imageNamed:@"background"] message.
What's wrong with my code ?

thank for your help,
Nicolas.
_______________________________________________
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
Peter Mark

Mark's Recording Studio A/S
Lundeskovsvej 3
2900 Hellerup
Denmark
Tel: +45 35366078 Fax: +45 35366038
www.marks-studio.dk
email@hidden

 _______________________________________________
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

  • Follow-Ups:
    • [OT] Re: background image in cocoa view AU
      • From: daniel <email@hidden>
  • Prev by Date: OT: Re: background image in cocoa view AU
  • Next by Date: Re: Tricks to avoid mutexes
  • Previous by thread: OT: Re: background image in cocoa view AU
  • Next by thread: [OT] Re: background image in cocoa view AU
  • Index(es):
    • Date
    • Thread