libzeug icon indicating copy to clipboard operation
libzeug copied to clipboard

Inconsistent Color representation

Open apopiak opened this issue 10 years ago • 3 comments

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)

apopiak avatar Feb 18 '15 12:02 apopiak

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

mjendruk avatar Feb 20 '15 15:02 mjendruk

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.

apopiak avatar Feb 20 '15 15:02 apopiak

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.

mjendruk avatar Feb 20 '15 15:02 mjendruk