Re: Pasting NSImage problems
Re: Pasting NSImage problems
- Subject: Re: Pasting NSImage problems
- From: Scott Stevenson <email@hidden>
- Date: Sun, 14 Oct 2007 23:29:25 -0700
On Oct 14, 2007, at 6:12 PM, Development wrote:
[newImage compositeToPoint:NSZeroPoint fromRect:imageRect
operation:NSCompositeSourceIn];
The actual compositing should only happen in drawRect (or a method
drawRect calls directly).
Paste is only called once, but your view may be asked to draw its
image very rapidly over and over (maybe 15 times per second, for
example). If the image only exists in the paste method, it will never
stay around long enough to make it to the screen.
The only thing the paste method should do is capture the image data
from the pasteboard and set the image object as an instance variable.
The idea is to keep it around for when it needs to be drawn in drawRect.
This stuff is covered in this tutorial:
"Cocoa Graphics with Quartz II"
<http://cocoadevcentral.com/d/intro_to_quartz_two/>
Scroll down to "Create and Display Images," but make sure to read the
rest of the tutorial as well, because it tells you how to keep image
data in memory.
The only difference for your situation is that you're getting the
data from the pasteboard instead of from a file on disk, but
everything else is essentially the same. There's a sample project
available for download at the bottom of the page.
For the dragging part, you can look at this:
"THCanvasView 1.0.1 and PhotoStacks Sample App"
<http://theocacao.com/document.page/503>
- Scott
_______________________________________________
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