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 will be copied to.

count

The number of rectables supplied in the read_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

The mutex flags; must be set to 0.

Library:

libscreen

Description:

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.

Returns:

0 if the operation was successful and the pixels are written to buf, or -1 if an error occurred (errno is set).