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

QPainter rotated by 180deg and drawing QPixmap on it, picture comes out as not rotated when printing

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.9.0, 5.11, 5.14, 5.15.0, 6.2.2, 6.6.1
    • GUI: Printing
    • None
    • Windows 7, Windows 10 64bit, Qt 5.9.x+ both 32 and 64 bit
    • Windows

    Description

      It is only happening on Windows when doing actual printing (even to MS XPS document writer virtual printer).

      Print output when painter is rotated by different angle works fine.

      Creating PDF by setting QPrinter::PdfFormat created pdf comes out correctly

      void PrintWidget::drawStuff(QPainter &p, const QRectF &dstRect)
      {
          p.save();
          p.setRenderHints(QPainter::SmoothPixmapTransform, true);
          p.translate(dstRect.topLeft());
          QRectF dst(0,0,dstRect.width(), dstRect.height()/2.0);
      
          if (!pm->isNull()) {
              QRectF src(0,0, pm->width(), pm->height());
              p.drawPixmap(dst, *pm, src);
      
              // translate and rotate so picture appears 180deg rotated
              p.translate(dstRect.width(), dstRect.height());
              p.rotate(180.0);
      
              // when printed on windows picture comes wrong /not rotated
              p.drawPixmap(dst, *pm, src);
          } else {
              p.drawText(dstRect, Qt::AlignCenter, "Picture not found!");
          }
          p.restore();
      }
      
      

       

      I attached full example.

      Left: Expected output, Right: what printout looks like:

      Attachments

        1. printbug.zip
          34 kB
        2. qtprintbug.png
          qtprintbug.png
          387 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            johnlayt John Layt
            ivang Ivan Golubovic
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes