• 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
Re: Applying color to template images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Applying color to template images
      • From: Mitchell Livingston <email@hidden>
References: 
 >Applying color to template images (From: Mitchell Livingston <email@hidden>)

  • Prev by Date: Re: core-data app design question
  • Next by Date: Re: Get error message about registered observers when Object receives dealloc message
  • Previous by thread: Applying color to template images
  • Next by thread: Re: Applying color to template images
  • Index(es):
    • Date
    • Thread