Re: Rendering an NSControl into a NSImage? (resolved)
Re: Rendering an NSControl into a NSImage? (resolved)
- Subject: Re: Rendering an NSControl into a NSImage? (resolved)
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 3 Apr 2003 12:20:08 -0800
On Wednesday, April 2, 2003, at 11:44 AM, Mark Alldritt wrote:
Hi,
Great thanks to John Randolph, Carl Norum, and Peter Mark. It was
Peter
Mark's code that finally cracked the problem. The following code
correctly
renders an NSControl into an NSImage. In the end, the only change
from my
original code was to call [snapshot setFlipped:YES].
- (NSImage*) proxyImage
{
NSRect sourceRect = [self frame];
NSImage *snapshot = [[NSImage alloc] initWithSize:sourceRect.size];
One suggestion: test for whether self is flipped here, and then you
have a general solution:
if ([self isFlipped])
[snapshot setFlipped:YES];
[snapshot lockFocus];
[self drawRect:sourceRect];
[snapshot unlockFocus];
return [snapshot autorelease];
}
For those that care, I've created a sample project that illustrates
what
I've learned about how to use drag and drop to copy controls:
http://www.latenightsw.com/archives/ControlDragAndDrop.hqx
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.