How to capture image off-screen NSWindow?

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:

alt text

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

alt text

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.

+3
source share
1

CGWindowListCreateImage CGWindow.h:

kCGWindowListOptionAll, kCGWindowListOptionOnScreenOnly: . windowID kCGNullWindowID.

, .

, kCGWindowListOptionIncludingWindow.

+2

Source: https://habr.com/ru/post/1771857/


All Articles