Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.9.1
-
None
-
Mac OS 10.12.5
Description
If I use a QPainter to paint a QImage target, using an image-based QBrush, and the painter's target allows transparency, the result will have some pixels arbitrarily fully transparent even though the QPainter's QBrush did not include any transparent pixels. This seems to have started happening recently; it didn't happen back on 5.7 and earlier.
For example, this simple code should save an image with all magenta pixels, but ends up having a line of fully transparent pixels near column ~5400:
#include <QCoreApplication> #include <QPainter> #include <QRectF> #include <QBrush> #include <QColor> #include <QImage> #include <QTransform> int main(int argc, char *argv[]) { QImage im(6000, 6000, QImage::Format_ARGB32); QImage brushIm(522, 546, QImage::Format_ARGB32); brushIm.fill(QColor(255,0,255)); QBrush brush(brushIm); brush.setTransform(QTransform::fromScale(0.626419669526,0.626419669526)); QPainter painter(&im); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); painter.setBrush(brush); QRectF rect(0, 0, 6000, 6000); QPainterPath path; path.addRect(rect); painter.drawPath(path); painter.end(); im.save("test.png"); }
I've attached the bad image it generates for me w/ the column of fully transparent pixels.
If I do not set `QPainter::SmoothPixmapTransform` then the issue does not happen.
If I pick a QImage format that does not allow transparency (Format_RGB32) then the issue does not happen.