title: How to get RGB values of QPixmap or QImage pixel - Qt, PyQt
body: <p>Based on this answer <a href="https://stackoverflow.com/a/769221/544721">https://stackoverflow.com/a/769221/544721</a> , I've made following code printing values in grabbed region:</p>
  
  <pre><code>import sys
  from PyQt4.QtGui import QPixmap, QApplication
  app = QApplication(sys.argv)
  
  # img is QImage type
  img = QPixmap.grabWindow(
          QApplication.desktop().winId(),
          x=00,
          y=100,
          height=20,
          width=20,
          ).toImage()
  
  for x in range(0,20):
      for y in range(0,20):
          print( "({},{}) = {}".format( x,y,(img.pixel(x,y)) ) )
  </code></pre>
  
  <p>But pixels are displayed like this:</p>
  
  <pre><code>(0,0) = 4285163107
  (0,1) = 4285163107
  (0,2) = 4285163107
  (0,3) = 4285163107
  (0,4) = 4285163107
  (0,5) = 4285163107
  </code></pre>
  
  <p>How to get RGB values of <code>QImage</code> (obtained from <code>QPixmap</code>) pixels ? (preferably, solution working in 16,24,32 screen bit depths) ?</p>
  
  <p>Example output:</p>
  
  <pre><code>(0,0) = (0,0,0)
  ...
  (10,15) = (127,15,256)
  </code></pre>
  
  <p>(Solution for Linux, written in Python3)</p>