• 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
NSImage change of behaviour?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage change of behaviour?


  • Subject: NSImage change of behaviour?
  • From: Graham Cox <email@hidden>
  • Date: Tue, 9 Mar 2010 13:25:02 +1100

Not sure if this is a bug or not, but it's certainly something that seems to have changed and I can find no mention of it in the release notes or elsewhere.

Typically when making an image for use as a drag image, I draw a bunch of things into an image, then copy it to itself with 50% alpha. This has always worked fine, using the following general approach:

NSImage* image = [[NSImage alloc] initWithSize:]

[image lockFocus];

// ... draw a bunch of stuff ...

// copy to self at 50% opacity
[image drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeCopy fraction:0.5];
[image unlockFocus];


I'm now finding that I don't get the semi-transparent image, but just a fully opaque image. I can workaround it like so:

NSImage* image = [[NSImage alloc] initWithSize:]

[image lockFocus];

// ... draw a bunch of stuff ...

[image unlockFocus];

[image lockFocus];
[image drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeCopy fraction:0.5];
[image unlockFocus];


So the extra unlock/lock seems to trigger some internal change that allows the transparent effect to work, but that wasn't needed in the past.

Anyone care to comment? Maybe the old way was always broken and it worked by chance, or maybe a change to image functionality didn't anticipate this usage pattern...

--Graham


_______________________________________________

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 change of behaviour?
      • From: Ken Ferry <email@hidden>
  • Prev by Date: Re: Using Core Data in Command Line utility
  • Next by Date: Re: Objective-C Garbage Collection problems
  • Previous by thread: Re: Using Core Data in Command Line utility
  • Next by thread: Re: NSImage change of behaviour?
  • Index(es):
    • Date
    • Thread