screen_read_display()

Take a screenshot of the display and store the resulting image in the specified buffer.

Synopsis:

#include <screen/screen.h>
 
int screen_read_display(screen_display_t disp,
                        screen_buffer_t buf,
                        int count,
                        const int *read_rects,
                        int flags)

Arguments:

disp

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

buf

The buffer where the resulting image will be stored.

count

The number of rectables supplied in the read_rects argument.

read_rects

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

flags

The mutex flags; must be set to 0.

Library:

libscreen

Description:

Function Type: Immediate Execution

This function takes a screenshot of a display 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. You need to be working within a privileged context so that you have full access to the display properties of the system. Therefore, a context which was created with the type SCREEN_DISPLAY_MANAGER_CONTEXT must be used. When capturing screenshots of multiple displays, you will need to make one screen_read_display() function call per display. The call blocks until the operation is completed. If count is 0 and read_rects is NULL, the entire display 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 display size. Scaling will be applied to make the screenshot fit into the buffer provided.

Returns:

0 if a the operation was successful and the pixels are written to buf, or -1 of an error occurred (errno is set; refer to /usr/include/errno.h for more details).