'Retrieve all pixels from a monitor. Pixels have to be RGB.
[1] 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'

def get_pixels(self, monitor):

    (width, height) = (monitor['width'], monitor['height'])
    (left, top) = (monitor['left'], monitor['top'])
    SRCCOPY = 13369376
    DIB_RGB_COLORS = BI_RGB = 0
    srcdc = memdc = bmp = None
    try:
        bmi = BITMAPINFO()
        bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER)
        bmi.bmiHeader.biWidth = width
        bmi.bmiHeader.biHeight = (- height)
        bmi.bmiHeader.biPlanes = 1
        bmi.bmiHeader.biBitCount = 24
        bmi.bmiHeader.biCompression = BI_RGB
        buffer_len = ((height * width) * 3)
        self.image = create_string_buffer(buffer_len)
        srcdc = windll.user32.GetWindowDC(0)
        memdc = windll.gdi32.CreateCompatibleDC(srcdc)
        bmp = windll.gdi32.CreateCompatibleBitmap(srcdc, width, height)
        windll.gdi32.SelectObject(memdc, bmp)
        windll.gdi32.BitBlt(memdc, 0, 0, width, height, srcdc, left, top, SRCCOPY)
        bits = windll.gdi32.GetDIBits(memdc, bmp, 0, height, self.image, bmi, DIB_RGB_COLORS)
        if (bits != height):
            raise ScreenshotError('MSS:    GetDIBits()    failed.')
    finally:
        if srcdc:
            windll.gdi32.DeleteObject(srcdc)
        if memdc:
            windll.gdi32.DeleteObject(memdc)
        if bmp:
            windll.gdi32.DeleteObject(bmp)
    (self.image[2:buffer_len:3], self.image[0:buffer_len:3]) = (self.image[0:buffer_len:3], self.image[2:buffer_len:3])
    return self.image
