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

Pasting NSImage problems


  • Subject: Pasting NSImage problems
  • From: Development <email@hidden>
  • Date: Sun, 14 Oct 2007 18:12:13 -0700

All right. I have a subclass of NSImageView. I want to be able to have it accept the paste operation when there is an image on the pasteboard. That part is easy enough. However when the paste function in the subclass is called nothing draws. What I am hoping for is that the image on the pasteboard will draw on top of the image in the view. (Making it movable and such is a nightmare I'll deal with when I get there.)

Here is the code I thought would work:

-(IBAction)paste:(id)sender
{
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSImage * newImage = [[NSImage alloc]initWithData:[pboard dataForType:NSTIFFPboardType]];
NSSize is =[newImage size];


NSRect imageRect = NSMakeRect(100.0,100.0,is.width,is.height);
NSBezierPath
*croppingPath = [NSBezierPath bezierPathWithRect:imageRect];

[[self image] lockFocus];
[[NSColor blackColor]set];
[croppingPath fill];
[newImage compositeToPoint:NSZeroPoint fromRect:imageRect operation:NSCompositeSourceIn];
[[self image] unlockFocus];


}

I have tried a number of different composite operations but the results are the same. I've spent the last couple of hours on Google, the mailing list archive, and the Dev site and if the answer was there I missed it. I also looked over my programming books with no luck. I thought that the code from the example sketch would help but it did not. So I'm missing something somewhere and hope some one out there can help me.

Dont know if you noticed or not but this whole drawing thing is driving me nuts. Every time I think I understand it I run in to something I cant wrap my head around.


_______________________________________________

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: Pasting NSImage problems
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Re: hiding table columns
  • Next by Date: Re: Pasting NSImage problems
  • Previous by thread: Re: TableColumn visibility issue
  • Next by thread: Re: Pasting NSImage problems
  • Index(es):
    • Date
    • Thread