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

Drawing text into a transparent ARGB32 buffer will blend the pixels with the color of the transparent pixels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • 4.8.x
    • 4.7.0
    • GUI: Text handling
    • None
    • Mac OS X 10.6.4, Windows 7

      If you fill an ARGB32 image with, say, 0x00ff0000, and draw text into it, you will see that the antialiasing pixels on the edges of the glyphs are tinted red. The same is visible if you draw into a black, transparent buffer and then draw this on top of e.g. a blue background.

      This means that a transparent ARGB32 image cannot be used to cache text, since the text will look out of place unless the transparent background has the same color as the destination pixels.

      The same problem is not visible with ARGB32_Premultiplied, or with a QPixmap (on raster or elsewhere.)

      Put the following into a widget's paint event to see:

              QImage image(400, 50, QImage::Format_ARGB32_Premultiplied );
              image.fill(0x00ff0000);
              {
                  QPainter p(&image);
                  p.setFont(font);
                  p.setPen(QColor("white"));
                  p.drawText(0, 30, "FOOBAR (argb32)");
              }
              QPainter p(this);
              p.fillRect(rect(), Qt::blue);
              p.drawImage(0, 0, image);
      

      The effect is especially visible on Mac OS X, but can be seen on Windows as well.

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

            Unassigned Unassigned
            esabraha Eskil Abrahamsen Blomfeldt
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes