screen_read_window()

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

Synopsis:

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

Arguments:

win
The handle of the window that is the target of the screenshot.
buf
The buffer where the pixel data is copied to.
count
The number of rectangles supplied in the save_rects argument.
save_rects
A pointer to (count * 4) integers that define the areas of the window that need to be grabbed for the screenshot.
flags
For future use. Pass 0 for now.

Library:

libscreen

Description:

Function Type: Apply Execution

This function takes the visible content 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. This call blocks until the operation is completed. If count is 0 and save_rects is NULL, the entire window is grabbed. Otherwise, save_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 is applied to make the screenshot fit into the buffer provided.

All visible content, from win and its child windows (if any), is copied to buf. You can access the visible content of win without having to share its buffer, and buffers of its children. For more information on sharing buffers when there's a window hierarchy, refer to the Screen Developer's Guide.

Returns:

0 if successful, or -1 if an error occurred (errno is set; refer to errno.h for more details).