• 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: NSImage glowing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage glowing


  • Subject: Re: NSImage glowing
  • From: Lee Ann Rucker <email@hidden>
  • Date: Tue, 04 Nov 2014 19:48:10 +0000
  • Thread-topic: NSImage glowing

If you want the same blue highlight that NSButton applies to template images, you can get the NSButtonCell to draw it into a graphics context and get an image that way - I answered this when you asked about buttons specifically back in June. (My bug requesting an NSImage method to do that is still open and presumably unloved) Once you've got your buttonCell configured, do this:


   NSRect bounds = NSZeroRect;
   bounds.size = [template size];

   NSBitmapImageRep *bmpImageRep =
      [NSBitmapImageRep imageRepWithSize:bounds.size scale:scale]; // Utility wrapper around imageRepWith32bitBuffer

   [NSGraphicsContext saveGraphicsState];
   NSGraphicsContext *bitmapContext =
      [NSGraphicsContext graphicsContextWithBitmapImageRep:bmpImageRep];
   [NSGraphicsContext setCurrentContext:bitmapContext];

   [buttonCell drawImage:template withFrame:bounds inView:nil];

   [NSGraphicsContext restoreGraphicsState];
   return bmpImageRep;


On Nov 4, 2014, at 10:41 AM, Alex Kac <email@hidden> wrote:

> I have an NSImage that looks like  in a mini-toolbar - kind of like Xcode.
>
> Now of course I can just create a hand-drawn selected version, but I like doing things like that in code. So I’d like to have code that takes the NSImage and makes it glow like Xcode here:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.dropbox.com_s_by642iw7xosnki7_Screenshot-25202014-2D11-2D04-252011.40.18.png-3Fdl-3D0&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNg&s=PSrnj94BQRWKM8dFv5gi7Tz3a3NH1_5gmiUvJHsFfP4&e=
>
> I’ve Googled this and I see a bunch of stuff, that I can’t get working at all. Most articles were for iOS and some repsonders even said “if I was using an NSImage, this would be easy - but for iOS you do…”.
>
> So… can anyone point me to the right place?
>
> _______________________________________________
>
> 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:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.apple.com_mailman_options_cocoa-2Ddev_lrucker-2540vmware.com&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNg&s=QsN7f2Wy2w3J4nIWtViq9WfFRo-Fwf46hQqveR8coB0&e=
>
> 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: NSImage glowing
      • From: Alex Kac <email@hidden>
References: 
 >NSImage glowing (From: Alex Kac <email@hidden>)

  • Prev by Date: Re: Editing NSOutlineView Group Item
  • Next by Date: Re: Editing NSOutlineView Group Item
  • Previous by thread: Re: NSImage glowing
  • Next by thread: Re: NSImage glowing
  • Index(es):
    • Date
    • Thread