NSView Screenshots Using Cocoa
While hacking away with the iPhone SDK & Cocoa, I discovered (from Ryan Britton) this code to capture a NSView as a NSImage.
ref: http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00771.html
Other references: http://www.cocoadev.com/index.pl?ScreenShotCode
[code]
NSView *view = self;
[view lockFocus];
NSBitmapImageRep *bitmap = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: [view bounds]] autorelease];
[view unlockFocus];
NSImage *image = [[[NSImage alloc] initWithSize: [view bounds].size] autorelease];
[image addRepresentation:bitmap];
[/code]
ref: http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00771.html
Other references: http://www.cocoadev.com/index.pl?ScreenShotCode
Comments