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

Windows print out to vector files results in bitmap

    XMLWordPrintable

Details

    • 739ad76846bc3d49472aacad9ed056cda314e26f

    Description

      tl;dr: QAlphaPaintEngine transparency flattening is way to aggressive. Causing unnecessary pre-rasterization of objects on top of transparent items.

      Run the following sample code and select a vector file print drive like Adobe PDF, doPDF, or Microsfot XPS Document Writer.

      Open the resulting file in view. Zoom far in to the letter 'A'. Notice the bottom half of the letter is in pre-rasterized bitmap.

      The line of text actually sits on top of the transparent rectangle. There is no need to rasterize the text to emulate the effect. Only objects covered by the transparent item need to be rasterized.

      QAlphaPaintEngine gathers bounding boxes of all transparent items and plays back the entire display list at the end of the page. This causes all objects intersecting the combined region to be rendered in low resolution bitmap.

      This same issue applies to PostScript output in 4.x.

      #include <QApplication>
      #include <QPrinter>
      #include <QPrintDialog>
      #include <QPainter>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QPrinter p;
          QPrintDialog d(&p);
          if(d.exec()) {
              QPainter painter(&p);
              painter.fillRect(100,100,200,200,QColor(100,0,0,50));
              QFont f("Helvetica", 30);
              painter.setFont(f);
              painter.drawText(100, 120, "A simple line of text.");
          }
          return 0;//a.exec();
      }
      
      
      

      Attachments

        1. document1.pdf
          15 kB
        2. qtbug33548.zip
          1 kB
        3. rect_rendered_with_gdiplus.pdf
          11 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-33548
          # Subject Branch Project Status CR V

          Activity

            People

              smd Jan Arve
              stephenju Stephen Chu
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes