Re: Pasting NSImage problems
Re: Pasting NSImage problems
- Subject: Re: Pasting NSImage problems
- From: Development <email@hidden>
- Date: Sun, 14 Oct 2007 23:35:44 -0700
The following code adds the pb image to the existing one at the
zeropoint. I'll make it movable later, but this is the fix I managed
after many hours
-(IBAction)paste:(id)sender
{
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSImage * newImage = [[NSImage alloc]initWithData:[pboard
dataForType:NSTIFFPboardType]];
NSImage * src = [[NSImage alloc]initWithData:[[self image]
TIFFRepresentation]];
NSSize is =[newImage size];
NSRect imageRect = NSMakeRect(0,0,is.width,is.height);
NSLog(@"Image: %f,%f %f,%
f",imageRect.origin.x,imageRect.origin.y,imageRect.size.width,imageRect.
size.height);
NSBezierPath * croppingPath = [NSBezierPath
bezierPathWithRect:imageRect];
[src lockFocus];
[[NSColor blackColor]set];
[croppingPath fill];
[newImage compositeToPoint:NSZeroPoint
operation:NSCompositeSourceOver];
[src unlockFocus];
[self setImage:src];
}
It's a little laggy but will function... of course the image I am
working with is a raw 2000px X 2000px Tiff so I expect a little slowness
_______________________________________________
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