Re: Applying color to template images
Re: Applying color to template images
- Subject: Re: Applying color to template images
- From: Brandon Walkin <email@hidden>
- Date: Sat, 29 Aug 2009 23:35:48 -0400
I have a category on NSImage that should do what you need:
- (NSImage *)tintedImageWithColor:(NSColor *)tint
{
NSSize size = [self size];
NSRect imageBounds = NSMakeRect(0, 0, size.width, size.height);
NSImage *copiedImage = [self copy];
[copiedImage lockFocus];
[tint set];
NSRectFillUsingOperation(imageBounds, NSCompositeSourceAtop);
[copiedImage unlockFocus];
return [copiedImage autorelease];
}
Brandon
On 2009-08-29, at 2:36 PM, Mitchell Livingston wrote:
Hello,
I want to use NSImage's built-in template images, but want to
replace the black color with different colors, such as gray or
orange. I feel like I'm missing something obvious, but I can't seem
to figure this out. Could someone point me in the right direction.
Thanks,
Mitch
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden