def tintImage(cls, img, tintColor): """ :type img: QImage :type tintColor: QColor """ p = QPainter(img) p.setCompositionMode(QPainter.CompositionMode_Screen) for x in range(0, img.width()): for y in range(0, img.height()): rgbColor = img.pixel(x, y) alpha = qAlpha(rgbColor) c = QColor(rgbColor) if alpha > 0: c.toHsl() l = c.lightnessF()() newColor = QColor.fromHslF(tintColor.hslHueF(), tintColor.hslSaturationF(), l) newColor.setAlpha(alpha) img.setPixel(x, y, newColor.rgba())