diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-08 04:39:11 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-08 04:39:11 (GMT) |
commit | ef16993782b834cb34ed0281925ddfc49535e78b (patch) | |
tree | 20a8c5f093f26d4365f92342b24fa447baeaf271 /src/declarative | |
parent | b513c31f34b9e5484889697314dc2ecb619b88a3 (diff) | |
download | Qt-ef16993782b834cb34ed0281925ddfc49535e78b.zip Qt-ef16993782b834cb34ed0281925ddfc49535e78b.tar.gz Qt-ef16993782b834cb34ed0281925ddfc49535e78b.tar.bz2 |
Fix Qt.tint() algorithm
QT-2424
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 1e60df4..41d55d7 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1234,17 +1234,13 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine else if (a == 0x00) finalColor = color; else { - uint src = tintColor.rgba(); - uint dest = color.rgba(); + qreal a = tintColor.alphaF(); + qreal inv_a = 1.0 - a; - uint res = (((a * (src & 0xFF00FF)) + - ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF; - res |= (((a * ((src >> 8) & 0xFF00FF)) + - ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00; - if ((src & 0xFF000000) == 0xFF000000) - res |= 0xFF000000; - - finalColor = QColor::fromRgba(res); + finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a, + tintColor.greenF() * a + color.greenF() * inv_a, + tintColor.blueF() * a + color.blueF() * inv_a, + a + inv_a * color.alphaF()); } return qScriptValueFromValue(engine, qVariantFromValue(finalColor)); |