From 80ca67e43fea432e58305b31c552d31306ac352f Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 28 Jul 2016 10:25:51 +0200 Subject: [PATCH] StyleHelper: Fixing alphaBlendedColors Change-Id: Ib2f5e37e213e221ecfcce876ed2f44013815ca46 Reviewed-by: Alessandro Portale --- src/libs/utils/stylehelper.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 78d20c55db5..088b7ff5154 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -66,14 +66,14 @@ QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &colorB) { - const QRgb base = colorA.rgba(); - const QRgb overlay = colorB.rgba(); - const qreal overlayIntensity = qAlpha(overlay) / 255.0; - return qRgba( - qMin(qRed(base) + qRound(qRed(overlay) * overlayIntensity), 0xff), - qMin(qGreen(base) + qRound(qGreen(overlay) * overlayIntensity), 0xff), - qMin(qBlue(base) + qRound(qBlue(overlay) * overlayIntensity), 0xff), - qMin(qAlpha(base) + qAlpha(overlay), 0xff)); + const int alpha = colorB.alpha(); + const int antiAlpha = 255 - alpha; + + return QColor( + (colorA.red() * antiAlpha + colorB.red() * alpha) / 255, + (colorA.green() * antiAlpha + colorB.green() * alpha) / 255, + (colorA.blue() * antiAlpha + colorB.blue() * alpha) / 255 + ); } qreal StyleHelper::sidebarFontSize()