2

Are there any ways to get pixel color under mouse cursor? (For not my windows).

I'm looking for cross-platform solutions. But it will be enought to provide mac os solution.

Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61

1 Answers1

1

If you have id of window you can try this: http://qt-project.org/doc/qt-4.8/qpixmap.html#grabWindow

 QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), x, y, 1, 1);
 QRgb pixelValue = pixmap.toImage().pixel(0,0);
Marek R
  • 32,568
  • 6
  • 55
  • 140
  • Thanks, I know this. But I need to grab pixel from any window, not only desktop. – Dmitry Sazonov Aug 05 '14 at 18:19
  • First of all you can pass proper (x,y) coordinates to hit proper window (this should be ok you you are using mouse). Secondly you can fetch pixel of specific widow if you will get its window id (just replace `QApplication::desktop()->winId()` with proper value). – Marek R Aug 05 '14 at 20:46
  • Gettings window is platform-specific. Seems there are no other ways – Dmitry Sazonov Aug 05 '14 at 21:01