Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    QGraphicsView, QLinearGradient -> bands of colors, no dithering, ugly result on arm target, linux, X11

    General and Desktop
    2
    10
    5292
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      billouparis last edited by

      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/View

      The 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(&#41;;
      

      }
      @

      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

      1 Reply Last reply Reply Quote 0
      • Z
        ZapB last edited by

        What colour depth does your device run at?

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply Reply Quote 0
        • B
          billouparis last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • B
            billouparis last edited by

            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

            1 Reply Last reply Reply Quote 0
            • Z
              ZapB last edited by

              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.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply Reply Quote 0
              • B
                billouparis last edited by

                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

                1 Reply Last reply Reply Quote 0
                • B
                  billouparis last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • B
                    billouparis last edited by

                    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?

                    1 Reply Last reply Reply Quote 0
                    • Z
                      ZapB last edited by

                      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.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply Reply Quote 0
                      • B
                        billouparis last edited by

                        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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post