From: Till T. <ro...@tt...> - 2012-01-10 21:35:34
|
Git commit 10ed185e8a1934d7c41e2ac2cda6b25a5df50646 by Till Theato. Committed on 10/01/2012 at 22:34. Pushed by theato into branch 'master'. Fix loading of color values in format 0xRRGGBB. This effected all effects with a color parameter not supporting the alpha channel. M +24 -22 src/choosecolorwidget.cpp http://commits.kde.org/kdenlive/10ed185e8a1934d7c41e2ac2cda6b25a5df50646 diff --git a/src/choosecolorwidget.cpp b/src/choosecolorwidget.cpp index 36eb893..8613819 100644 --- a/src/choosecolorwidget.cpp +++ b/src/choosecolorwidget.cpp @@ -35,28 +35,30 @@ static QColor stringToColor(QString strColor) int intval = 0; if (strColor.startsWith("0x")) { - // Format must be 0xRRGGBBAA - intval = strColor.toUInt(&ok, 16); - color.setRgb( ( intval >> 24 ) & 0xff, // r - ( intval >> 16 ) & 0xff, // g - ( intval >> 8 ) & 0xff, // b - ( intval ) & 0xff ); // a - } else if (strColor.startsWith("#") && strColor.length() == 9) { - // Format must be #AARRGGBB - strColor = strColor.replace('#', "0x"); - intval = strColor.toUInt(&ok, 16); - color.setRgb( ( intval >> 16 ) & 0xff, // r - ( intval >> 8 ) & 0xff, // g - ( intval ) & 0xff, // b - ( intval >> 24 ) & 0xff ); // a - } else if (strColor.startsWith("#") && strColor.length() == 7) { - // Format must be #RRGGBB - strColor = strColor.replace('#', "0x"); - intval = strColor.toUInt(&ok, 16); - color.setRgb( ( intval >> 16 ) & 0xff, // r - ( intval >> 8 ) & 0xff, // g - ( intval ) & 0xff, // b - 0xff ); // a + if (strColor.length() == 10) { + // 0xRRGGBBAA + intval = strColor.toUInt(&ok, 16); + color.setRgb( ( intval >> 24 ) & 0xff, // r + ( intval >> 16 ) & 0xff, // g + ( intval >> 8 ) & 0xff, // b + ( intval ) & 0xff ); // a + } else { + // 0xRRGGBB, 0xRGB + color.setNamedColor(strColor.replace(0, 2, "#")); + } + } else { + if (strColor.length() == 9) { + // #AARRGGBB + strColor = strColor.replace('#', "0x"); + intval = strColor.toUInt(&ok, 16); + color.setRgb( ( intval >> 16 ) & 0xff, // r + ( intval >> 8 ) & 0xff, // g + ( intval ) & 0xff, // b + ( intval >> 24 ) & 0xff ); // a + } else { + // #RRGGBB, #RGB + color.setNamedColor(strColor); + } } return color; |