title: Python Win32API bitmap.GetBitmapBits()
body: <p>just a quick question that I haven't been able to find any details about: I am using the python win32api to capture a screen shot of my computer. I want to roll my own image compression algorithm (for fun, I don't expect professional level results), but I am struggling to understand the pixel data I am getting from the bitmap itself. Here is the relevant code:</p>
  
  <pre><code>width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)
  height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)
  left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)
  top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)
  
  hwin = win32gui.GetDesktopWindow()
  hwindc = win32gui.GetWindowDC(hwin)
  srcdc = win32ui.CreateDCFromHandle(hwindc) 
  
  memdc = srcdc.CreateCompatibleDC()                                             
  
  bmp = win32ui.CreateBitmap()    
  bmp.CreateCompatibleBitmap(srcdc, width, height)    
  memdc.SelectObject(bmp)         
  
  
  memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY) 
  bmpinfo = bmp.GetInfo()
  bmpInt = bmp.GetBitmapBits(False)
  </code></pre>
  
  <p>GetBitmapBits(False) returns an integer array / tuple. But I can't find any information about how bmpInt relates to pixel data. The output looks like this:</p>
  
  <pre><code>123,1,-1,-13,-55,2,23,123 ...
  </code></pre>
  
  <p>How do these correspond to the RGB values of each pixel? Are every 3 ints one pixel? Or is there an alpha channel? Also, why are there negative numbers? For reference, here is the documentation: <a href="http://docs.activestate.com/activepython/2.4/pywin32/PyCBitmap__GetBitmapBits_meth.html" rel="nofollow">http://docs.activestate.com/activepython/2.4/pywin32/PyCBitmap__GetBitmapBits_meth.html</a> 
  There's no explanation there...</p>