• 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
Odd message when taking a photo of an NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odd message when taking a photo of an NSView


  • Subject: Odd message when taking a photo of an NSView
  • From: alexander reichstadt <email@hidden>
  • Date: Wed, 7 Dec 2005 10:07:50 +0100

Hi,

I need to take a photo of an NSView with a couple of caveats though. The view is in memory but not part of any window at the time of being photographed. I don't want the color distortions that come with taking the dataWithPDFInsideRect route, and neither the performance issues.

Enclosed the code I found to work quite well, but I am still getting a console message now I would like to bring to cease:

"GrP not requesting _registerDragTypes because the window is dying already"

Any ideas where this comes from?

Here the code:

+ (NSImage *)captureImageOfView:(NSView *)inView
{
NSWindow *window;
NSBitmapImageRep *rep;
NSImage *image;

NSView *nva = [inView retain];

window = [[NSWindow alloc] initWithContentRect:NSMakeRect (-5000.0, -5000.0, [nva frame].size.width, [nva frame].size.height) styleMask:NSBorderlessWindowMask
backing:NSBackingStoreNonretained defer:NO];
[window unregisterDraggedTypes];
[window setLevel:NSScreenSaverWindowLevel + 1];
[window setHasShadow:NO];
[window setAlphaValue:1.0];
[window setContentView:nva];
[window display];

[[window contentView] lockFocus];
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[[window contentView] frame]];
[[window contentView] unlockFocus];
[window orderOut:nil];
[window close];

image = [[[NSImage alloc] initWithSize:[rep size]] autorelease];
[image addRepresentation:rep];
[nva release];
return image;
}


Thank you.
Alex
_______________________________________________
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
  • Follow-Ups:
    • Re: Odd message when taking a photo of an NSView
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: tableview shouldSelectRow called twice ?
  • Next by Date: XCode Build issues
  • Previous by thread: Re: tableview shouldSelectRow called twice ?
  • Next by thread: Re: Odd message when taking a photo of an NSView
  • Index(es):
    • Date
    • Thread