def _make_image_from_buffer(self, hCaptureBitmap):
    from PIL import Image
    bmp_info = BITMAPINFO()
    bmp_header = BITMAPFILEHEADER()
    hdc = user32.GetDC(None)

    bmp_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER)

    DIB_RGB_COLORS = 0
    gdi.GetDIBits(hdc,
      hCaptureBitmap,
      0,0,
      None, byref(bmp_info),
      DIB_RGB_COLORS
    )

    bmp_info.bmiHeader.biSizeImage = int(bmp_info.bmiHeader.biWidth *abs(bmp_info.bmiHeader.biHeight) * (bmp_info.bmiHeader.biBitCount+7)/8);
    size = (bmp_info.bmiHeader.biWidth, bmp_info.bmiHeader.biHeight )
    # print(size)
    pBuf = (c_char * bmp_info.bmiHeader.biSizeImage)()

    gdi.GetBitmapBits(hCaptureBitmap, bmp_info.bmiHeader.biSizeImage, pBuf)

    return Image.frombuffer('RGB', size, pBuf, 'raw', 'BGRX', 0, 1)
dataset/ETHPy150Open chriskiehl/pyrobot/pyrobot.py/Robot._make_image_from_buffer/original