Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-67995

QGradient with ObjectBoundingMode produces an incorrect result

    XMLWordPrintable

Details

    Description

      The bug itself was found in the QtSvg module, but it also can be reproduced by a simple example: 

      #include <QGuiApplication>
      #include <QImage>
      #include <QPainter>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
      
          QImage img(200, 200, QImage::Format_ARGB32);
          img.fill(Qt::transparent);
      
          QPainter p(&img);
          p.setRenderHint(QPainter::Antialiasing);
          p.setTransform(QTransform(1, 0, -0.57735026919, 1, 0, 0)); // skewX(-30)
      
          QRadialGradient rg(0.5, 0.5, 0.5, 0.5, 0.5);
          rg.setCoordinateMode(QGradient::ObjectBoundingMode);
          rg.setColorAt(0, Qt::white);
          rg.setColorAt(1, Qt::black);
      
          QBrush brush(rg);
          brush.setTransform(QTransform(0.86602540378, 0.5, -0.5, 0.86602540378, 0, 0)); // rotate(30)
      
          p.setPen(Qt::NoPen);
          p.setBrush(brush);
      
          p.drawRect(100, 40, 110, 110);
      
          p.end();
      
          img.save("test.png");
      
          return 0;
      }
      

      Attachments

        1. actual.png
          actual.png
          2 kB
        2. expected.png
          expected.png
          3 kB
        3. test.svg
          0.4 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vgt Eirik Aavitsland
              razrfalcon Evgeniy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes