Gradient Banding Problem (Qt 4.6, 18bit display)
I evaluate "Qt Everywhere 4.6.3" for an application running on Windows Mobile 6.5 Pro (18bit color depth display).
It seems Qt automatically switches color rendering to 16bit color depth as all gradients have banding-problems (lines).
Are there any solutions for this? I use QPainter and QGradient and already tried to draw an overlay QPixmap with dithering noise at the end of the paint method with no effect. When drawing QPixmaps with both gradients and dithering-noise in it it works well. Is there a solution for either forcing Qt to use the 18bit available or to draw QGradients with a dithering mask / effect.
Thanks in advance,
Is it an option to just put your gradients in images beforehand, and using those? That is usually faster than rendering them using QGradient. At least, that is the recommended way of working for Quick.
Thanks for your reply. Some controls are flexible in height and width. So it would be a lot more flexible to work with QGradient. I also tried to draw the gradient into a pixmap first, adding a tiled dither-bitmap to it and in the end draw this pixmap with the control painter. But this had no other effect than directly drawing gradient and mask one after another. The banding lines are still visible. It seems the 16bit conversion is done directly by QPainter. So what I need is either real 18bit drawing or the possibility to create 24bit pixmaps by code (gradient + overlay dithering bitmap).
What happens if you draw on a QImage first (in as many bits as you like), and use that?
As for using a pixmap approach, perhaps you can leverage QSS for that (the style sheet system). It supports the border-image property, that you can use to use an image to style an object of unknown size. It will auto stretch in an appropriate way.
Thanks a lot for the hint with QImage. I get better results when drawing into a QImage first (ARGB_32 format) and afterwards drawing this image with the control painter. I'm currently experimenting with different composition modes for QPainter and different dithering masks to get the gradients as smooth as possible. Thanks for the help.
The reason is that QPixmap is directly tied to the underlying hardware capabilities. QImage is purely software. On the plus side, you can put your QImage generation into a worker thread so as not to block the main GUI thread with those expensive gradient calculations.