I am trying to get an image of an off-screen window for use in animation based on CALayer, but no matter what method I try, I can not get the image from the other side. Here is the code I used in a custom subclass NSWindowin my project:
CGImageRef windowImage = CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionAll,
(CGWindowID)[self windowNumber],
kCGWindowImageDefault);
Here's what the image should look like:

and here is what I get (ignore a slightly larger size - this is my mistake in rendering the image):

Can anyone see where I'm wrong? Oddly enough, Quartz Debug can see the image of the window without problems, but the example code with Apple’s son Grab cannot.
source
share