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
          Stephen Chu
        2. qtbug33548.zip
          1 kB
          Friedemann Kleint
        3. rect_rendered_with_gdiplus.pdf
          11 kB
          Jan Arve

        Issue Links

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

          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