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

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


References: 
 >Re: Pasting NSImage problems (From: Erik Buck <email@hidden>)
 >Re: Pasting NSImage problems (From: Development <email@hidden>)

  • Prev by Date: Re: Validation error in a relationship? (in coredata)
  • Next by Date: Re: Core Data: Cross-model relationships
  • Previous by thread: Re: Pasting NSImage problems
  • Next by thread: Simple dealloc question
  • Index(es):
    • Date
    • Thread