Re: NSView to NSBitmapRep Without an NSWindow?
Re: NSView to NSBitmapRep Without an NSWindow?
- Subject: Re: NSView to NSBitmapRep Without an NSWindow?
- From: Troy Stephens <email@hidden>
- Date: Tue, 13 Sep 2005 15:21:53 -0700
Invoking -drawRect: directly isn't recommended, and may not produce
the desired results. Capture from an offscreen window should work,
however. (You'll need to ask the offscreen view to "-
displayIfNeeded" first, as it won't otherwise have drawn anything
into the window backing store yet.) There's also some new NSView API
in Tiger that you can use for this purpose.
See my reply to the list on this topic, back in July:
http://lists.apple.com/archives/Cocoa-dev/2005/Jul/msg01352.html
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
On Sep 10, 2005, at 9:34 AM, email@hidden wrote:
You might try
- (NSImage *)imageFromView:(NSView *)theView
{
NSRect viewBounds = [theView bounds];
NSImage *image = [[NSImage alloc] initWithSize:viewBounds.size];
[image setFlipped:YES]; // or maybe you won't need this
[image lockFocus];
NSEraseRect(viewBounds);
[theView drawRect: viewBounds ];
[image unlockFocus];
return [image autorelease];
}
And then extract the NSBitmapImageRep from the NSImage
HTH,
James
On Sep 8, 2005, at 12:36 PM, Seth Willits wrote:
Is there any way to get an NSBitmapRep of the contents in an
NSView *without* that view being in a window? Nothing I've tried
works. Even briefly placing the view in a window way of screen
doesn't work.
Thanks,
--
Seth Willits
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden