libzeug
libzeug copied to clipboard
Inconsistent Color representation
This parsing
Color Color::fromString(const std::string & string, bool * ok)
{
//[...]
if (hexString.size() == 6)
hexString = "FF" + hexString; // results in ARGB
//[...]
}
is inconsitent with the following functions
unsigned int Color::rgba() const
Color::Color(int red, int green, int blue, int alpha)
Mhm, this corresponds to the way it is implemented in Qt. http://doc.qt.io/qt-5/qcolor.html http://doc.qt.io/qt-5/qcolor.html#rgba
I don't think that Qt parses Strings as ARGB and then only offers rgba() getter functions and that was what I was getting at.
The 2 functions on the bottom are totally fine, the fromString()
method is the one with the weird behaviour.
Color::rgba()
returns an unsigned int that somewhat looks like this alpha red green blue
. This corresponds exactly to QColor::rgba()
which returns an QRgb
which is "An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int."
The Qt equivalent to Color::fromString()
is QColor::setNamedColor()
which also reads hex values as #AARRGGBB
.
I'm sorry, but I haven't yet understood what's weird about it.