You can use createMaskFromColor to create a bitmap for white pixels, then use drawPixmap to overwrite them with a different color.
pix = QPixmap("test.png") mask = pix.createMaskFromColor(QColor(255, 255, 255), Qt.MaskOutColor) p = QPainter(pix) p.setPen(QColor(0, 0, 255)) p.drawPixmap(pix.rect(), mask, mask.rect()) p.end()
Note that createMaskFromColor converts pixmap to QImage , so you should try using QImage if possible.
source share