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