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

QGradient with ObjectBoundingMode produces an incorrect result

XMLWordPrintable

      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;
      }
      

        1. test.svg
          0.4 kB
          Evgeniy
        2. actual.png
          2 kB
          Evgeniy
        3. expected.png
          3 kB
          Evgeniy
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes