2034QColor QColor::toRgb()
const noexcept
2036 if (!isValid() || cspec == Rgb)
2041 if (cspec != ExtendedRgb)
2042 color.ct.argb.alpha = ct.argb.alpha;
2043 color.ct.argb.pad = 0;
2048 if (ct.ahsv.saturation == 0 || ct.ahsv.hue == USHRT_MAX) {
2050 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsv.value;
2055 const float h = ct.ahsv.hue == 36000 ? 0.0f : ct.ahsv.hue / 6000.0f;
2056 const float s = ct.ahsv.saturation /
float(USHRT_MAX);
2057 const float v = ct.ahsv.value /
float(USHRT_MAX);
2058 const int i =
int(h);
2059 const float f = h - i;
2060 const float p = v * (1.0f - s);
2063 const float q = v * (1.0f - (s * f));
2067 color.ct.argb.red = qRound(q * USHRT_MAX);
2068 color.ct.argb.green = qRound(v * USHRT_MAX);
2069 color.ct.argb.blue = qRound(p * USHRT_MAX);
2072 color.ct.argb.red = qRound(p * USHRT_MAX);
2073 color.ct.argb.green = qRound(q * USHRT_MAX);
2074 color.ct.argb.blue = qRound(v * USHRT_MAX);
2077 color.ct.argb.red = qRound(v * USHRT_MAX);
2078 color.ct.argb.green = qRound(p * USHRT_MAX);
2079 color.ct.argb.blue = qRound(q * USHRT_MAX);
2083 const float t = v * (1.0f - (s * (1.0f - f)));
2087 color.ct.argb.red = qRound(v * USHRT_MAX);
2088 color.ct.argb.green = qRound(t * USHRT_MAX);
2089 color.ct.argb.blue = qRound(p * USHRT_MAX);
2092 color.ct.argb.red = qRound(p * USHRT_MAX);
2093 color.ct.argb.green = qRound(v * USHRT_MAX);
2094 color.ct.argb.blue = qRound(t * USHRT_MAX);
2097 color.ct.argb.red = qRound(t * USHRT_MAX);
2098 color.ct.argb.green = qRound(p * USHRT_MAX);
2099 color.ct.argb.blue = qRound(v * USHRT_MAX);
2107 if (ct.ahsl.saturation == 0 || ct.ahsl.hue == USHRT_MAX) {
2109 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsl.lightness;
2110 }
else if (ct.ahsl.lightness == 0) {
2112 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = 0;
2115 const float h = ct.ahsl.hue == 36000 ? 0.0f : ct.ahsl.hue / 36000.0f;
2116 const float s = ct.ahsl.saturation /
float(USHRT_MAX);
2117 const float l = ct.ahsl.lightness /
float(USHRT_MAX);
2121 temp2 = l * (1.0f + s);
2123 temp2 = l + s - (l * s);
2125 const float temp1 = (2.0f * l) - temp2;
2126 float temp3[3] = { h + (1.0f / 3.0f),
2128 h - (1.0f / 3.0f) };
2130 for (
int i = 0; i != 3; ++i) {
2131 if (temp3[i] < 0.0f)
2133 else if (temp3[i] > 1.0f)
2136 const float sixtemp3 = temp3[i] * 6.0f;
2137 if (sixtemp3 < 1.0f)
2138 color.ct.array[i+1] = qRound((temp1 + (temp2 - temp1) * sixtemp3) * USHRT_MAX);
2139 else if ((temp3[i] * 2.0f) < 1.0f)
2140 color.ct.array[i+1] = qRound(temp2 * USHRT_MAX);
2141 else if ((temp3[i] * 3.0f) < 2.0f)
2142 color.ct.array[i+1] = qRound((temp1 + (temp2 -temp1) * (2.0f /3.0f - temp3[i]) * 6.0f) * USHRT_MAX);
2144 color.ct.array[i+1] = qRound(temp1 * USHRT_MAX);
2146 color.ct.argb.red = color.ct.argb.red == 1 ? 0 : color.ct.argb.red;
2147 color.ct.argb.green = color.ct.argb.green == 1 ? 0 : color.ct.argb.green;
2148 color.ct.argb.blue = color.ct.argb.blue == 1 ? 0 : color.ct.argb.blue;
2154 const float c = ct.acmyk.cyan /
float(USHRT_MAX);
2155 const float m = ct.acmyk.magenta /
float(USHRT_MAX);
2156 const float y = ct.acmyk.yellow /
float(USHRT_MAX);
2157 const float k = ct.acmyk.black /
float(USHRT_MAX);
2159 color.ct.argb.red = qRound((1.0f - (c * (1.0f - k) + k)) * USHRT_MAX);
2160 color.ct.argb.green = qRound((1.0f - (m * (1.0f - k) + k)) * USHRT_MAX);
2161 color.ct.argb.blue = qRound((1.0f - (y * (1.0f - k) + k)) * USHRT_MAX);
2165 color.ct.argb.alpha = qRound(USHRT_MAX *
float(castF16(ct.argbExtended.alphaF16)));
2166 color.ct.argb.red = qRound(USHRT_MAX * qBound(0.0f,
float(castF16(ct.argbExtended.redF16)), 1.0f));
2167 color.ct.argb.green = qRound(USHRT_MAX * qBound(0.0f,
float(castF16(ct.argbExtended.greenF16)), 1.0f));
2168 color.ct.argb.blue = qRound(USHRT_MAX * qBound(0.0f,
float(castF16(ct.argbExtended.blueF16)), 1.0f));
3044 0, 16711935, 8355967, 5570645, 4177983, 3342387, 2785322, 2387419,
3045 2088991, 1856881, 1671193, 1519266, 1392661, 1285533, 1193709, 1114129,
3046 1044495, 983055, 928440, 879575, 835596, 795806, 759633, 726605,
3047 696330, 668477, 642766, 618960, 596854, 576273, 557064, 539094,
3048 522247, 506422, 491527, 477483, 464220, 451673, 439787, 428511,
3049 417798, 407608, 397903, 388649, 379816, 371376, 363302, 355573,
3050 348165, 341059, 334238, 327685, 321383, 315319, 309480, 303853,
3051 298427, 293191, 288136, 283253, 278532, 273966, 269547, 265268,
3052 261123, 257106, 253211, 249431, 245763, 242201, 238741, 235379,
3053 232110, 228930, 225836, 222825, 219893, 217038, 214255, 211543,
3054 208899, 206320, 203804, 201348, 198951, 196611, 194324, 192091,
3055 189908, 187774, 185688, 183647, 181651, 179698, 177786, 175915,
3056 174082, 172287, 170529, 168807, 167119, 165464, 163842, 162251,
3057 160691, 159161, 157659, 156186, 154740, 153320, 151926, 150557,
3058 149213, 147893, 146595, 145321, 144068, 142837, 141626, 140436,
3059 139266, 138115, 136983, 135869, 134773, 133695, 132634, 131590,
3060 130561, 129549, 128553, 127572, 126605, 125653, 124715, 123792,
3061 122881, 121984, 121100, 120229, 119370, 118524, 117689, 116866,
3062 116055, 115254, 114465, 113686, 112918, 112160, 111412, 110675,
3063 109946, 109228, 108519, 107818, 107127, 106445, 105771, 105106,
3064 104449, 103800, 103160, 102527, 101902, 101284, 100674, 100071,
3065 99475, 98887, 98305, 97730, 97162, 96600, 96045, 95496,
3066 94954, 94417, 93887, 93362, 92844, 92331, 91823, 91322,
3067 90825, 90334, 89849, 89368, 88893, 88422, 87957, 87497,
3068 87041, 86590, 86143, 85702, 85264, 84832, 84403, 83979,
3069 83559, 83143, 82732, 82324, 81921, 81521, 81125, 80733,
3070 80345, 79961, 79580, 79203, 78829, 78459, 78093, 77729,
3071 77370, 77013, 76660, 76310, 75963, 75619, 75278, 74941,
3072 74606, 74275, 73946, 73620, 73297, 72977, 72660, 72346,
3073 72034, 71725, 71418, 71114, 70813, 70514, 70218, 69924,
3074 69633, 69344, 69057, 68773, 68491, 68211, 67934, 67659,
3075 67386, 67116, 66847, 66581, 66317, 66055, 65795, 65537