• 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: Drawing an image as hilighted?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing an image as hilighted?


  • Subject: Re: Drawing an image as hilighted?
  • From: Ricky Sharp <email@hidden>
  • Date: Sun, 4 Sep 2005 19:08:35 -0500


On Sep 4, 2005, at 3:57 PM, Stéphane Sudre wrote:

Colin Cornaby wrote:


Is there any Apple supplied code to draw an image as hilighted? For example, the way an image hilights when it's clicked in iPhoto's bottom toolbar (I know they're buttons which have that functionality built in, but I'm not using buttons).


If by highlighting, you mean darkened, it's quite easy to achieve IIRC.


- create a new NSImage the size of your image

- lock the new image

- draw your image

- draw a black rectangle with a specific alpha alpha value (0.33f maybe but YMMV)

- unlock the new image

And then you have your highlighted image.

Or, if you don't want to make the alternate image, render the image followed by something like this:


[[[NSColor blackColor] colorWithAlphaComponent:0.33] set];

NSRectFillUsingOperation (theRect, NSCompositeSourceOver);


As Stéphane mentioned, try different alpha values. You may also want to try different colors and composite modes. I think the above two approaches may apply shading in any areas of your image that are completely transparent.


___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Drawing an image as hilighted? (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Creating a codeless, friendly NSArrayController
  • Next by Date: CoreData NSArrayController's in IB
  • Previous by thread: Re: Drawing an image as hilighted?
  • Next by thread: Re.: [ANN] LogSurfer monitors logfiles [OT]
  • Index(es):
    • Date
    • Thread