Take a screenshot of the window and stores the resulting image in the specified buffer.


#include <screen/screen.h>
int screen_read_window(screen_window_t win,
                       screen_buffer_t buf,
                       int count,
                       const int *save_rects,
                       int flags)



The handle of the window that is the target of the screenshot.


The buffer where the pixel data will be copied to.


The number of rectables supplied in the read_rects argument.


A pointer to (count * 4) integers that define the areas of the window that need to be grabbed for the screenshot.


The mutex flags; must be set to 0.




Function Type: Apply Execution

This function takes a screenshot of a window and stores the result in a user-provided buffer. The buffer can be a pixmap buffer or a window buffer. The buffer must have been created with the usage flag SCREEN_USAGE_NATIVE in order for the operation to succeed. The call blocks until the operation is completed. If count is 0 and read_rects is NULL, the entire window is grabbed. Otherwise, read_rects must point to count * 4 integers defining rectangles in screen coordinates that need to be grabbed. Note that the buffer size does not have to match the window size. Scaling will be applied to make the screenshot fit into the buffer provided.


0 if the operation was successful and the pixels are written to buf, or -1 if an error occurred (errno is set; refer to /usr/include/errno.h for more details). Note that the error may also have been caused by any delayed execution function that's just been flushed.