Re: Image missing in Palette?
Re: Image missing in Palette?
- Subject: Re: Image missing in Palette?
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 21 Mar 2002 16:11:08 -0600
[NSImage imageNamed:@"myImage"] is looking in the applications main bundle.
With a palette running inside IB, the main bundle is IB's bundle.
Use [[NSBundle bundleForClass:[self class]] pathForResource:@"myImage"
ofType:@"tiff"];
Then use the path to initialize an NSImage. I types this in mail so there
may be minor errors.
----- Original Message -----
From: "Thomas Lachand-Robert" <email@hidden>
To: <email@hidden>
Sent: Thursday, March 21, 2002 2:13 PM
Subject: Image missing in Palette?
>
Is there a special location to put images for a palette? I have a custom
>
control whose (simplified) drawRect is as follows:
>
- (void)drawRect:(NSRect)rect
>
{
>
NSRect bounds = [self bounds];
>
NSImage *image = [[NSImage imageNamed:@"myImage"] retain];
>
>
if (!image) {
>
NSLog(@"Error in TLRTranslation: image missing");
>
[[NSColor redColor] set];
>
[NSBezierPath fillRect:bounds];
>
}
>
else {
>
NSSize size = [image size];
>
[image drawInRect:bounds fromRect:NSMakeRect(0, 0, size.width,
>
size.height)
>
operation:NSCompositeSourceOver fraction:1.0];
>
}
>
}
>
>
This works in the original project (with file "myImage.tiff" in Resources
>
folder), but now I'm trying to create a palette for this control. The
>
palette loads, but I get only the red rectangle and the Log message, even
>
though the file "myImage.tiff" is in the Resources folder of the palette,
>
too. So maybe I should put it somewhere else?
>
>
Thomas Lachand-Robert
>
********************** email@hidden
>
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
>
_______________________________________________
>
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.
_______________________________________________
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.