cginternals / libzeug

deprecated: C++ sanctuary for small but powerful and frequently required, stand alone features.
MIT License
16 stars 13 forks source link

Inconsistent Color representation #111

Open apopiak opened 9 years ago

apopiak commented 9 years ago

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)
mjendruk commented 9 years ago

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

apopiak commented 9 years ago

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.

mjendruk commented 9 years ago

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.