在下面显示的代码中,颜色的hsl色调分量有一个与预期不同的值。
对于: r:255 g:168 b:177,它给出了353的hsl色调,但在其他web工具上,它产生354。
QColor rgb(c);
QColor hsl = rgb.toHsl();
QColor hsv = rgb.toHsv();
// RGB
int r = rgb.red();
int g = rgb.green();
int b = rgb.blue();
// HSB
int hslh = qMax(hsl.hslHue(), 0);
int hsls = hsl.hslSaturation();
int hsll = hsl.lightness();这是一个已知的问题吗?
发布于 2014-11-24 20:43:05
问题似乎仅仅是Qt在请求整数输出时如何舍入颜色分量值。为了在您的示例中说明:
QColor col(255,168,177);
std::cout << "hue_float " << col.hslHueF()*360.0f << std::endl;
std::cout << "hue_int " << col.hslHue() << std::endl;产出:
hue_float 353.79
hue_int 353https://stackoverflow.com/questions/27111854
复制相似问题