• 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: Making a opaque copy of an NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making a opaque copy of an NSImage


  • Subject: Re: Making a opaque copy of an NSImage
  • From: Graham Cox <email@hidden>
  • Date: Tue, 6 Oct 2009 14:15:07 +1100


On 02/10/2009, at 6:39 AM, David Alter wrote:

*I have an NSImage that I would like to make a transparent version for
dragging. I have used - (void)dissolveToPoint:(NSPoint)aPoint
fraction:(CGFloat)delta to do this in the past. That appears to be getting
deprecated and I would like to update my code. What is the suggested way of
doing things. I still need to support 10.4 and up.


To make a drag image from an existing image is pretty easy - just instantiate a new image of the same size and copy the first into the second, applying a value < 1.0 for fraction:


- (NSImage*) dragImageFromImage:(NSImage*) inImage { NSImage* dragImage = [[NSImage alloc] initWithSize:[inImage size]];

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


	return [dragImage autorelease];
}


(warning: typed into Mail)

--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


References: 
 >Making a opaque copy of an NSImage (From: David Alter <email@hidden>)

  • Prev by Date: Re: Checking whether a file is a genuine PDF file
  • Next by Date: Re: Rounded NSBox/NSView?
  • Previous by thread: Re: Making a opaque copy of an NSImage
  • Next by thread: CoreAnimation: image is too large
  • Index(es):
    • Date
    • Thread