I need to take the contents of an NSView and put them in an NSImage, for an experimental project. Is this possible? I did some Googling, tried two methods that I found - but they didn't really work. Any suggestions?
+3
A:
[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];
Chuck
2010-07-15 01:02:18
Thank you very much.
Debashis
2010-07-15 02:11:53
+1 It's worth noting that, although this is the right way in general, there are some cases where it will not work, eg views like `NSOpenGLView` that have their own OpenGL rendering context. In that case you need to get the pixel data directly and create a bitmap rep from it, which is a bit less neat.
walkytalky
2010-07-19 01:11:06
+2
A:
I thinkt, Debashis is thinking more of things like http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Images/Images.html#//apple_ref/doc/uid/TP40003290-CH208-BCIIIJFB
Greetings
Objective Interested Person
2010-07-15 09:09:31