NSTableView and NSImageCell
NSTableView and NSImageCell
- Subject: NSTableView and NSImageCell
- From: David Dauer <email@hidden>
- Date: Mon, 12 Apr 2004 09:13:17 +0200
Hello,
I want to draw a badge over and image that I load into my table. The strange
thing is, that when I do [NSImageView setImage:myImageWithBadge];
(myimageBithBadge created in awakeFromNib) it displays the image WITH badge
correctly. In my tableview datasource I use "return myImageWithBadge", I
only get the image without the overlayed badge image.
The code:
@implementation NSImage (NSImageAdditions)
- (void)applyBadge:(NSImage *)badge withAlpha:(float)alpha
{
NSImage *badgeImage;
badgeImage = [[badge copy] autorelease];
[self lockFocus];
[[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationHigh];
[badgeImage drawAtPoint:NSMakePoint([self size].width - [badgeImage
size].width,0)
fromRect:NSZeroRect
operation:NSCompositeSourceOver
fraction:alpha];
[self unlockFocus];
}
@end
- (void)awakeFromNib
{
tempImage = [[NSImage imageNamed:@"normalImage"] copy];
[tempImage applyBadge:[NSImage imageNamed:@"badge"] withAlpha:0.75];
[theImageView setImage:tempImage];
}
Thanks for any suggestion
David
_______________________________________________
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.