QGraphicsView, QLinearGradient -> bands of colors, no dithering, ugly result on arm target, linux, X11
-
I have this very simple application that I try to run on my iMX51 target running Linux and X11.
It simply draws a linear gradient on a graphicsScene/ViewThe result is not as linear as the name could let think. I see ugly bands of colors one next to the others, without any dithering at all.
The application is started with '-graphicssystem raster' option.!http://i52.tinypic.com/f2toqr.jpg(test)!
1 - Can you help me understand what is wrong with this?
2 - If I use the option '-graphicssystem opengl' then the result is better, the gradient appears smoother, but the drawing performances are completely down, although I have an openGL hardware accelerator!
I'm really looking to understand point 1, if you could help me on this, I will be very pleased.
Thank you,
here is the source code,
@
#include <QtGui/QApplication>
#include "widget.h"
#include <QLinearGradient>
#include "mygraphicsview.h"
#include "myscene.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
myGraphicsView myView;
myScene scene;QLinearGradient gradient(0,0,500,500); scene.setBackgroundBrush(gradient); myView.setScene(&scene); myView.setGeometry(0,0,500,500); myView.show(); return a.exec();
}
@myScene and myGraphicsView do nothing in particular, they are only derived class, but with no code at all.
EDIT: please wrap code with @-tags, thanks. Gerolf
-
What colour depth does your device run at?
-
The device is able to display nice smooth gradients, since it is working when using -graphicssystem opengl option, right?
Or maybe I don't exactly understand your question? -
Our device (display) is capable of 18bit depth only, but there is no dithering performed to translate from 16 to 18 bits. So I am looking for a way to set the raster painter in 24bit, so that the transformation from 24 bits to 18 can be performed with linear interpolation.
Can you help me with this?
Thank you,
Bill -
Does it work better if you configure your QT build with the option:
@-depths 18@
I have not delved into QT to see what colour depth it uses internally for calculating gradients. I am not sure if it is always forced to be 24 or whether it uses whatever is specified to Qt at configure time. Worth a shot though.
If that fails and you don't fancy getting your hands dirty in Qt, you could always pre-render your dithered gradients. This might not be a bad idea anyway since gradients are fiendishly expensive to calculate.
-
Unfortunately I can not recompile our Qt for embedded linux version. Any other hints?
Maybe i could check by someway what bitdepth is the surface my raster painter is trying to paint on?
Bill -
Any idea how I could use the QScreen class? I can not construct one instance of it because I have absolutely no idea how to provide a display_id in the constructor.
Bill -
OK so we finally got results by calling methods of QScreen class, here they are:
QScreen:
[Screen]
Depth= 16 =>Returns the depth of the framebuffer, in bits per pixel.
Note that the returned depth is the number of bits each pixel fills rather than the number of significant bits, so 24bpp and 32bpp express the same range of colors (8 bits of red, green and blue).Pixel format= 7 => QImage::Format_RGB167The image is stored using a 16-bit RGB format (5-6-5).
Pixel type= 0 =>QScreen::NormalPixel0Red-green-blue (RGB)
Pixel pixmap depth= 16 (bits per pixel)So how do I manage to have this working in 24 bits now?
-
I am afraid that I do not know and I do not have the time to dig into this right now. The only option I could suggest woudl be to pre-render your gradients with dithering and then display those rather than painting them in code each time. This is probably a good idea anyway as gradients are very expensive to compute.
-
My real problem is that I am not using gradient but PNG images composed of gradient from opaque to full transparency. Then I have no idea how to render these images without the non-dithering effect then.