Re: Making a opaque copy of an NSImage
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