Hi,
Is there anyway to get the color of a pixel on a QWidget on a known pixel position?
Thanks,
Hi,
Is there anyway to get the color of a pixel on a QWidget on a known pixel position?
Thanks,
Òscar Llarch i Galán
See QPixmap::grabWidget() with a proper second argument (or QPixmap::grabWindow() when it is outside your app) and then use QPixmap::toImage() and finally get the color using QImage::pixel().
Hi,
Thanks, but is a slow solution. I need a faster way to get it.
Òscar Llarch i Galán
Did your widget change a lot? if not, you can cache a QImage inside the paint method and use that for determinating the color at a specific point. Beside that I don't know a solution for your problem with Qt. You can of course use the operating API to get that information.
Hi,
Thanks Lykurg,
Yes, it changes very fast as it shows images captured from a camera. Before you tell me to get the image pointer, I need to tell you that as there is a thread that emits signals with image pointers, this pointers can point on deleted memory. Sending copy images slows down my application a lot.Did your widget change a lot?
Will take a look to use OS specific API to get it. I think that on Windows I can get the HDC pointer to get this information.
Thanks,
Òscar Llarch i Galán
Bookmarks