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

CompositionMode_Screen wrong with drawImage

    XMLWordPrintable

Details

    • Linux/X11, Windows
    • 2536d73adc (qt/qtbase/dev) 5234c6f716 (qt/qtbase/6.3) 5234c6f716 (qt/tqtc-qtbase/6.3) 2536d73adc (qt/tqtc-qtbase/dev) 6f987d3644 (qt/qtbase/6.2) 6f987d3644 (qt/tqtc-qtbase/6.2) 1ff363521d (qt/tqtc-qtbase/5.15)

    Description

      When using QPainter::drawImage with the CompositionMode_Screen mode there seem to be an off by one / rounding ( ? )  error.

      The result is always (if < 255) more than one would expect.

      For example:

      QImage dst(4, 4, QImage::Format_Grayscale8);
      dst.fill(0);
      QPainter p(&dst);
      p.setCompositionMode(QPainter::CompositionMode_Screen);
      qDebug() << "Original color is" << dst.constScanLine(0)[0];
      
      QImage src(4, 4, QImage::Format_Grayscale8);
      src.fill(0);
      p.drawImage(0, 0, src);
      p.end();
      qDebug() << "New color is" << dst.constScanLine(0)[0];
      

       Results in

      Source color is 0
      Color is 1
      

      while the expected result when screening with zero would be the same as the destination color (0 in this case).

      (See Wikipedia and also the documentation: "whereas screening a color with black leaves the color unchanged")
      This behavior is the same on all tested Image formats (GrayScale8,  RGB, ARGB_PREMUL).

      When replacing the drawImage call with fillRect with the same color the result is as expected / correct.

      (I sadly didn't found the drawImage on RasterImages implementation in QTs code otherwise i could bee more precise. Pointers to the correct code path would be welcome tho)

      Attachments

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

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            sleepprogger peter lustig
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes