• 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
Re: NSView to NSBitmapRep Without an NSWindow?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSView to NSBitmapRep Without an NSWindow? (From: Seth Willits <email@hidden>)
 >Re: NSView to NSBitmapRep Without an NSWindow? (From: email@hidden)

  • Prev by Date: Adding hit test to circleview question.
  • Next by Date: Re: NSFileHandle thread safe ?
  • Previous by thread: Re: NSView to NSBitmapRep Without an NSWindow?
  • Next by thread: Re: Cocoa-dev Digest, Vol 2, Issue 1343
  • Index(es):
    • Date
    • Thread