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

Mac :artifacts around text painted onto a transparently filled QImage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 4.7.0
    • GUI: Painting
    • None
    • OS X 10.6
    • macOS

    Description

      Text placed into a QImage and then painted does not look as good as text painted directly.
      Setting the fill to white improves the quality, but it is still inferior to the direct painting.

      #include <QApplication>
      #include <QMainWindow>
      #include <QMenuBar>
      #include <QAction>
      #include <QPainter>
      
      class test: public QMainWindow
      {
      
      public:
          test() : QMainWindow()
          {
          }
      
      protected:
          void paintEvent(QPaintEvent *event)
          {
              QRect r = rect();
      
                  QRect r1 = QRect(0, 0, r.width(), r.height() / 2);
      
                  QImage image(r1.size(), QImage::Format_ARGB32_Premultiplied);
                  image.fill(Qt::transparent);
                  QPainter pp(&image);
                  QString testText = "Lorem ipsum summo lucilius an eos, eum liber tation tamquam ne, graeco laboramus has in. An nec quaeque habemus, timeam delenit perpetua in vel, eu sit unum mucius. Ad vix augue everti dissentias, duis omnesque incorrupte nam at, sale feugiat ex pro. Odio dicit laoreet ius cu, per in invenire hendrerit definiebas, vel erant aliquip delenit an. Augue postea nec ad, illud dolorem complectitur his ex. Cu malis apeirian nam, ut erat ferri latine usu, solum impedit euripidis mea at. Pro mutat graeci qualisque te, qui omnis munere feugiat cu.";
                  pp.drawText(r1, "QImage(Raster):\n" + testText);
                  pp.end();
      
                  QRect r2 = QRect(0, r1.height(), r.width(), r.height() - r1.height());
                  QPainter p(this);
                  p.drawImage(0, 0, image);
                  p.drawText(r2, "CoreGraphics:\n" + testText);
              }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app (argc, argv);
      
              test *t = new test;
              t->show();
      
          return app.exec();
      }
      
      

      Attachments

        Issue Links

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

          Activity

            People

              sletta Gunnar Sletta
              dettman Dean Dettman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes