(self, monitor)
return self.cls_image(bytearray(self._data), monitor)
Retrieve all pixels from a monitor. Pixels have to be RGB.

        In the code, there are a few interesting things:

        [1] bmi.bmiHeader.biHeight = -height

        A bottom-up DIB is specified by setting the height to a
        positive number, while a top-down DIB is specified by
        setting the height to a negative number.
        https://msdn.microsoft.com/en-us/library/ms787796.aspx
        https://msdn.microsoft.com/en-us/library/dd144879%28v=vs.85%29.aspx


        [2] bmi.bmiHeader.biBitCount = 32
            image_data = create_string_buffer(height * width * 4)

        We grab the image in RGBX mode, so that each word is 32bit
        and we have no striding.
        Inspired by https://github.com/zoofIO/flexx


        [3] bmi.bmiHeader.biClrUsed = 0
            bmi.bmiHeader.biClrImportant = 0

        When biClrUsed and biClrImportant are set to zero, there
        is "no" color table, so we can read the pixels of the bitmap
        retrieved by gdi32.GetDIBits() as a sequence of RGB values.
        Thanks to http://stackoverflow.com/a/3688682
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.

        In the code, there are a few interesting things:

        [1] bmi.bmiHeader.biHeight = -height

        A bottom-up DIB is specified by setting the height to a
        positive number, while a top-down DIB is specified by
        setting the height to a negative number.
        https://msdn.microsoft.com/en-us/library/ms787796.aspx
        https://msdn.microsoft.com/en-us/library/dd144879%28v=vs.85%29.aspx


        [2] bmi.bmiHeader.biBitCount = 32
            image_data = create_string_buffer(height * width * 4)

        We grab the image in RGBX mode, so that each word is 32bit
        and we have no striding.
        Inspired by https://github.com/zoofIO/flexx


        [3] bmi.bmiHeader.biClrUsed = 0
            bmi.bmiHeader.biClrImportant = 0

        When biClrUsed and biClrImportant are set to zero, there
        is "no" color table, so we can read the pixels of the bitmap
        retrieved by gdi32.GetDIBits() as a sequence of RGB values.
        Thanks to http://stackoverflow.com/a/3688682
        """

        srcdc, memdc = self._get_srcdc(), MSS.memdc
        width, height = monitor["width"], monitor["height"]

        if (self._bbox["height"], self._bbox["width"]) != (height, width):
            self._bbox = monitor
            self._bmi.bmiHeader.biWidth = width
            self._bmi.bmiHeader.biHeight = -height  # Why minus? [1]
            self._data = ctypes.create_string_buffer(width * height * 4)  # [2]
            if MSS.bmp:
                self.gdi32.DeleteObject(MSS.bmp)
            MSS.bmp = self.gdi32.CreateCompatibleBitmap(srcdc, width, height)
            self.gdi32.SelectObject(memdc, MSS.bmp)

        self.gdi32.BitBlt(
            memdc,
            0,
            0,
            width,
            height,
            srcdc,
            monitor["left"],
            monitor["top"],
            SRCCOPY | CAPTUREBLT,
        )
        bits = self.gdi32.GetDIBits(
            memdc, MSS.bmp, 0, height, self._data, self._bmi, DIB_RGB_COLORS
        )
        if bits != height:
            raise ScreenShotError("gdi32.GetDIBits() failed.")

        return self.cls_image(bytearray(self._data), monitor)
def _grab_impl ( self , monitor ) : # type: (Monitor) -> ScreenShot srcdc , memdc = self . _get_srcdc ( ) , MSS . memdc width , height = monitor [ "width" ] , monitor [ "height" ] if ( self . _bbox [ "height" ] , self . _bbox [ "width" ] ) != ( height , width ) : self . _bbox = monitor self . _bmi . bmiHeader . biWidth = width self . _bmi . bmiHeader . biHeight = - height # Why minus? [1] self . _data = ctypes . create_string_buffer ( width * height * 4 ) # [2] if MSS . bmp : self . gdi32 . DeleteObject ( MSS . bmp ) MSS . bmp = self . gdi32 . CreateCompatibleBitmap ( srcdc , width , height ) self . gdi32 . SelectObject ( memdc , MSS . bmp ) self . gdi32 . BitBlt ( memdc , 0 , 0 , width , height , srcdc , monitor [ "left" ] , monitor [ "top" ] , SRCCOPY | CAPTUREBLT , ) bits = self . gdi32 . GetDIBits ( memdc , MSS . bmp , 0 , height , self . _data , self . _bmi , DIB_RGB_COLORS ) if bits != height : raise ScreenShotError ( "gdi32.GetDIBits() failed." ) return self . cls_image ( bytearray ( self . _data ) , monitor )