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

Windows print out to vector files results in bitmap for elements on top of transparent or gradient items

    XMLWordPrintable

Details

    Description

      The fix from QTBUG-33548 does not correct all scenarios. Consider the following code that place text behind and in front of a transparent rectangle. Both text items are rasterized when only the one behind needs to be.

      Also the text in front of a gradient is rasterized unnecessarily. See the attached PDF example file.

      #include <QtPrintSupport>
      #include <QtGui>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QPrinter p;
          QPrintDialog d(&p);
          if(d.exec()) {
              QPainter painter(&p);
              QFont f("Helvetica", 30);
              painter.setFont(f);
              painter.setPen(Qt::gray);
      
              painter.drawText(100, 50, "A simple line of text behind.");
      
              painter.fillRect(0,40,1200,70,QColor(100,0,0,50));
      
              painter.drawText(100, 120, "A simple line of text in front.");
      
              QLinearGradient linearGrad(QPointF(0, 0), QPointF(100, 100));
              linearGrad.setColorAt(0, Qt::black);
              linearGrad.setColorAt(1, Qt::white);
              linearGrad.setSpread(QGradient::RepeatSpread);
      
              painter.fillRect(0,300,1200,70,linearGrad);
      
              painter.drawText(100, 315, "A simple line of text on top of a gradient.");
          }
          return 0;
      }
      

      Attachments

        1. document1.pdf
          31 kB
          Stephen Chu
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            johnlayt John Layt
            stephenju Stephen Chu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes