Re: Rendering a View into an Image
Re: Rendering a View into an Image
- Subject: Re: Rendering a View into an Image
- From: James DiPalma <email@hidden>
- Date: Mon, 15 Oct 2001 09:01:52 -0700
[image lockFocus] might help to cache views.
I use lock focus to cache cell images for dragging and think views can
also be cached with lockFocus.
[dragImage lockFocus];
[cell drawWithFrame:NSMakeRect(0, 0, cellFrame.size.width,
cellFrame.size.height) inView:self];
[dragImage unlockFocus];
If there is a better way, I'd be interested in hearing about it.
-jim
On Wednesday, October 10, 2001, at 07:55 AM, Charles Jolley wrote:
NSBitmapImageRep *myBitmap = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:[myView bounds]];
That's not an NSImage, but you can turn it into one, something like
this:
My experience has shown this to work only if the view is visible in the
window. In fact, if a view is only partially visible, then it will
only render the visible portion into the image.