Does anyone know how to "snapshot" a complete SKView
or SKScene
into an NSImage
?
We have been able to use the textureFromNode
API to create an SKTexture
from a node and all its children. But so far we can't figure out a way to extract the image data into say an NSImage
. We are building a mixed Cocoa
/ SpriteKit
app where we need to extract small thumbnails of scenes.
Again, this seems possible on iOS (to get a UIImage
) using drawViewHierarchyInRect
:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, scale);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
But how to do this on Cocoa
with NSImage
? Help.