(self, monitor)
return self.cls_image(data, monitor)
Retrieve all pixels from a monitor. Pixels have to be RGB.
Retrieve all pixels from a monitor. Pixels have to be RGB.
Retrieve all pixels from a monitor . Pixels have to be RGB .
def _grab_impl(self, monitor):
        # type: (Monitor) -> ScreenShot
        """ Retrieve all pixels from a monitor. Pixels have to be RGB. """

        ximage = self.xlib.XGetImage(
            self._get_display(),
            self.drawable,
            monitor["left"],
            monitor["top"],
            monitor["width"],
            monitor["height"],
            PLAINMASK,
            ZPIXMAP,
        )

        try:
            bits_per_pixel = ximage.contents.bits_per_pixel
            if bits_per_pixel != 32:
                raise ScreenShotError(
                    "[XImage] bits per pixel value not (yet?) implemented: {}.".format(
                        bits_per_pixel
                    )
                )

            raw_data = ctypes.cast(
                ximage.contents.data,
                POINTER(c_ubyte * monitor["height"] * monitor["width"] * 4),
            )
            data = bytearray(raw_data.contents)
        finally:
            # Free
            self.xlib.XDestroyImage(ximage)

        return self.cls_image(data, monitor)
def _grab_impl ( self , monitor ) : # type: (Monitor) -> ScreenShot ximage = self . xlib . XGetImage ( self . _get_display ( ) , self . drawable , monitor [ "left" ] , monitor [ "top" ] , monitor [ "width" ] , monitor [ "height" ] , PLAINMASK , ZPIXMAP , ) try : bits_per_pixel = ximage . contents . bits_per_pixel if bits_per_pixel != 32 : raise ScreenShotError ( "[XImage] bits per pixel value not (yet?) implemented: {}." . format ( bits_per_pixel ) ) raw_data = ctypes . cast ( ximage . contents . data , POINTER ( c_ubyte * monitor [ "height" ] * monitor [ "width" ] * 4 ) , ) data = bytearray ( raw_data . contents ) finally : # Free self . xlib . XDestroyImage ( ximage ) return self . cls_image ( data , monitor )