Find color of QRect
-
-
@JonB is it right if I assume, that once an element is rendered, there is no way to get it's color again, if I'm not responsible for coloring it?
I used
QScreen::grabWindow
to get the color of a window but that only works if the window is not covered by another element. Is there a possibility to get colors for something on screen, even if it is covered? Somehow Qt has to know what to render, once the covering window is gone, right? -
In some cases it is possible to get the pixel value of an element. The mechanism is going to depend on what that element is. For example, QWidget::grab() facilitates retrieving a QPixMap, which can be converted to a QImage. The color of a pixel is retrievable via QImage::pixelColor(). That color isn't going to take into account any blending the windowing system is doing for transparency.
-
haven't looked because I had no reason to use it, but some graphics APIs have a ValueOfPixel() function to get the attributes of an on-screen pixel. Seems of limited use though, since it is assumed that if you put down a pixel in the first place then you should know how you rendered it. FWIW, if your QPainter is rendering to a pixmap/bitmap then you should be able to get the rendered value from that backing.