From d661d4a188bde6cadab60f7d1df632fbc5163dd0 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 7 Jan 2016 12:13:40 +0100 Subject: [PATCH] Utils: Fix maskToColorAndAlpha() This produced wrong disabled icons on some platforms. Change-Id: I3a80ac7f5e1fd5027d665e5791df802c78e2113a Reviewed-by: Alessandro Portale --- src/libs/utils/icon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/icon.cpp b/src/libs/utils/icon.cpp index 9e7c9de47e0..a9d2a23e680 100644 --- a/src/libs/utils/icon.cpp +++ b/src/libs/utils/icon.cpp @@ -50,9 +50,9 @@ static QPixmap maskToColorAndAlpha(const QPixmap &mask, const QColor &color) QRgb *bitsStart = reinterpret_cast(result.bits()); const QRgb *bitsEnd = bitsStart + result.width() * result.height(); const QRgb tint = color.rgb() & 0x00ffffff; - const qreal alpha = color.alphaF(); + const QRgb alpha = QRgb(color.alpha()); for (QRgb *pixel = bitsStart; pixel < bitsEnd; ++pixel) { - QRgb pixelAlpha = ~(*pixel & 0xff) * alpha; + QRgb pixelAlpha = (((~*pixel) & 0xff) * alpha) >> 8; *pixel = (pixelAlpha << 24) | tint; } return QPixmap::fromImage(result);