qcolor.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qcolor.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qcolor.h"-
35#include "qcolor_p.h"-
36#include "qnamespace.h"-
37#include "qdatastream.h"-
38#include "qvariant.h"-
39#include "qdebug.h"-
40-
41#include <stdio.h>-
42#include <limits.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46/*!-
47 \class QColor-
48 \brief The QColor class provides colors based on RGB, HSV or CMYK values.-
49-
50 \ingroup painting-
51 \ingroup appearance-
52 \inmodule QtGui-
53-
54-
55 A color is normally specified in terms of RGB (red, green, and-
56 blue) components, but it is also possible to specify it in terms-
57 of HSV (hue, saturation, and value) and CMYK (cyan, magenta,-
58 yellow and black) components. In addition a color can be specified-
59 using a color name. The color name can be any of the SVG 1.0 color-
60 names.-
61-
62 \table-
63 \header-
64 \li RGB \li HSV \li CMYK-
65 \row-
66 \li \inlineimage qcolor-rgb.png-
67 \li \inlineimage qcolor-hsv.png-
68 \li \inlineimage qcolor-cmyk.png-
69 \endtable-
70-
71 The QColor constructor creates the color based on RGB values. To-
72 create a QColor based on either HSV or CMYK values, use the-
73 toHsv() and toCmyk() functions respectively. These functions-
74 return a copy of the color using the desired format. In addition-
75 the static fromRgb(), fromHsv() and fromCmyk() functions create-
76 colors from the specified values. Alternatively, a color can be-
77 converted to any of the three formats using the convertTo()-
78 function (returning a copy of the color in the desired format), or-
79 any of the setRgb(), setHsv() and setCmyk() functions altering \e-
80 this color's format. The spec() function tells how the color was-
81 specified.-
82-
83 A color can be set by passing an RGB string (such as "#112233"),-
84 or an ARGB string (such as "#ff112233") or a color name (such as "blue"),-
85 to the setNamedColor() function.-
86 The color names are taken from the SVG 1.0 color names. The name()-
87 function returns the name of the color in the format-
88 "#RRGGBB". Colors can also be set using setRgb(), setHsv() and-
89 setCmyk(). To get a lighter or darker color use the lighter() and-
90 darker() functions respectively.-
91-
92 The isValid() function indicates whether a QColor is legal at-
93 all. For example, a RGB color with RGB values out of range is-
94 illegal. For performance reasons, QColor mostly disregards illegal-
95 colors, and for that reason, the result of using an invalid color-
96 is undefined.-
97-
98 The color components can be retrieved individually, e.g with-
99 red(), hue() and cyan(). The values of the color components can-
100 also be retrieved in one go using the getRgb(), getHsv() and-
101 getCmyk() functions. Using the RGB color model, the color-
102 components can in addition be accessed with rgb().-
103-
104 There are several related non-members: QRgb is a typdef for an-
105 unsigned int representing the RGB value triplet (r, g, b). Note-
106 that it also can hold a value for the alpha-channel (for more-
107 information, see the \l {QColor#Alpha-Blended-
108 Drawing}{Alpha-Blended Drawing} section). The qRed(), qBlue() and-
109 qGreen() functions return the respective component of the given-
110 QRgb value, while the qRgb() and qRgba() functions create and-
111 return the QRgb triplet based on the given component-
112 values. Finally, the qAlpha() function returns the alpha component-
113 of the provided QRgb, and the qGray() function calculates and-
114 return a gray value based on the given value.-
115-
116 QColor is platform and device independent. The QColormap class-
117 maps the color to the hardware.-
118-
119 For more information about painting in general, see the \l{Paint-
120 System} documentation.-
121-
122 \tableofcontents-
123-
124 \section1 Integer vs. Floating Point Precision-
125-
126 QColor supports floating point precision and provides floating-
127 point versions of all the color components functions,-
128 e.g. getRgbF(), hueF() and fromCmykF(). Note that since the-
129 components are stored using 16-bit integers, there might be minor-
130 deviations between the values set using, for example, setRgbF()-
131 and the values returned by the getRgbF() function due to rounding.-
132-
133 While the integer based functions take values in the range 0-255-
134 (except hue() which must have values within the range 0-359),-
135 the floating point functions accept values in the range 0.0 - 1.0.-
136-
137 \section1 Alpha-Blended Drawing-
138-
139 QColor also support alpha-blended outlining and filling. The-
140 alpha channel of a color specifies the transparency effect, 0-
141 represents a fully transparent color, while 255 represents a fully-
142 opaque color. For example:-
143-
144 \snippet code/src_gui_painting_qcolor.cpp 0-
145-
146 The code above produces the following output:-
147-
148 \image alphafill.png-
149-
150 The alpha channel of a color can be retrieved and set using the-
151 alpha() and setAlpha() functions if its value is an integer, and-
152 alphaF() and setAlphaF() if its value is qreal (double). By-
153 default, the alpha-channel is set to 255 (opaque). To retrieve and-
154 set \e all the RGB color components (including the alpha-channel)-
155 in one go, use the rgba() and setRgba() functions.-
156-
157 \section1 Predefined Colors-
158-
159 There are 20 predefined QColors described by the Qt::GlobalColor enum,-
160 including black, white, primary and secondary colors, darker versions-
161 of these colors and three shades of gray. QColor also recognizes a-
162 variety of color names; the static colorNames() function returns a-
163 QStringList color names that QColor knows about.-
164-
165 \image qt-colors.png Qt Colors-
166-
167 Additionally, the Qt::color0, Qt::color1 and Qt::transparent colors-
168 are used for special purposes.-
169-
170 Qt::color0 (zero pixel value) and Qt::color1 (non-zero pixel value)-
171 are special colors for drawing in QBitmaps. Painting with Qt::color0-
172 sets the bitmap bits to 0 (transparent; i.e., background), and painting-
173 with Qt::color1 sets the bits to 1 (opaque; i.e., foreground).-
174-
175 Qt::transparent is used to indicate a transparent pixel. When painting-
176 with this value, a pixel value will be used that is appropriate for the-
177 underlying pixel format in use.-
178-
179 \section1 The HSV Color Model-
180-
181 The RGB model is hardware-oriented. Its representation is close to-
182 what most monitors show. In contrast, HSV represents color in a way-
183 more suited to the human perception of color. For example, the-
184 relationships "stronger than", "darker than", and "the opposite of"-
185 are easily expressed in HSV but are much harder to express in RGB.-
186-
187 HSV, like RGB, has three components:-
188-
189 \list-
190 \li H, for hue, is in the range 0 to 359 if the color is chromatic (not-
191 gray), or meaningless if it is gray. It represents degrees on the-
192 color wheel familiar to most people. Red is 0 (degrees), green is-
193 120, and blue is 240.-
194-
195 \inlineimage qcolor-hue.png-
196-
197 \li S, for saturation, is in the range 0 to 255, and the bigger it is,-
198 the stronger the color is. Grayish colors have saturation near 0; very-
199 strong colors have saturation near 255.-
200-
201 \inlineimage qcolor-saturation.png-
202-
203 \li V, for value, is in the range 0 to 255 and represents lightness or-
204 brightness of the color. 0 is black; 255 is as far from black as-
205 possible.-
206-
207 \inlineimage qcolor-value.png-
208 \endlist-
209-
210 Here are some examples: pure red is H=0, S=255, V=255; a dark red,-
211 moving slightly towards the magenta, could be H=350 (equivalent to-
212 -10), S=255, V=180; a grayish light red could have H about 0 (say-
213 350-359 or 0-10), S about 50-100, and S=255.-
214-
215 Qt returns a hue value of -1 for achromatic colors. If you pass a-
216 hue value that is too large, Qt forces it into range. Hue 360 or 720 is-
217 treated as 0; hue 540 is treated as 180.-
218-
219 In addition to the standard HSV model, Qt provides an-
220 alpha-channel to feature \l {QColor#Alpha-Blended-
221 Drawing}{alpha-blended drawing}.-
222-
223 \section1 The HSL Color Model-
224-
225 HSL is similar to HSV. Instead of value parameter from HSV,-
226 HSL has the lightness parameter.-
227 The lightness parameter goes from black to color and from color to white.-
228 If you go outside at the night its black or dark gray. At day its colorful but-
229 if you look in a really strong light a things they are going to white and-
230 wash out.-
231-
232 \section1 The CMYK Color Model-
233-
234 While the RGB and HSV color models are used for display on-
235 computer monitors, the CMYK model is used in the four-color-
236 printing process of printing presses and some hard-copy-
237 devices.-
238-
239 CMYK has four components, all in the range 0-255: cyan (C),-
240 magenta (M), yellow (Y) and black (K). Cyan, magenta and yellow-
241 are called subtractive colors; the CMYK color model creates color-
242 by starting with a white surface and then subtracting color by-
243 applying the appropriate components. While combining cyan, magenta-
244 and yellow gives the color black, subtracting one or more will-
245 yield any other color. When combined in various percentages, these-
246 three colors can create the entire spectrum of colors.-
247-
248 Mixing 100 percent of cyan, magenta and yellow \e does produce-
249 black, but the result is unsatisfactory since it wastes ink,-
250 increases drying time, and gives a muddy colour when printing. For-
251 that reason, black is added in professional printing to provide a-
252 solid black tone; hence the term 'four color process'.-
253-
254 In addition to the standard CMYK model, Qt provides an-
255 alpha-channel to feature \l {QColor#Alpha-Blended-
256 Drawing}{alpha-blended drawing}.-
257-
258 \sa QPalette, QBrush, QApplication::setColorSpec()-
259*/-
260-
261#define QCOLOR_INT_RANGE_CHECK(fn, var) \-
262 do { \-
263 if (var < 0 || var > 255) { \-
264 qWarning(#fn": invalid value %d", var); \-
265 var = qMax(0, qMin(var, 255)); \-
266 } \-
267 } while (0)-
268-
269#define QCOLOR_REAL_RANGE_CHECK(fn, var) \-
270 do { \-
271 if (var < qreal(0.0) || var > qreal(1.0)) { \-
272 qWarning(#fn": invalid value %g", var); \-
273 var = qMax(qreal(0.0), qMin(var, qreal(1.0))); \-
274 } \-
275 } while (0)-
276-
277/*****************************************************************************-
278 QColor member functions-
279 *****************************************************************************/-
280-
281/*!-
282 \enum QColor::Spec-
283-
284 The type of color specified, either RGB, HSV, CMYK or HSL.-
285-
286 \value Rgb-
287 \value Hsv-
288 \value Cmyk-
289 \value Hsl-
290 \value Invalid-
291-
292 \sa spec(), convertTo()-
293*/-
294-
295/*!-
296 \enum QColor::NameFormat-
297-
298 How to format the output of the name() function-
299-
300 \value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. \c{#RRGGBB}).-
301 \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. \c{#AARRGGBB}).-
302-
303 \sa name()-
304*/-
305-
306/*!-
307 \fn Spec QColor::spec() const-
308-
309 Returns how the color was specified.-
310-
311 \sa Spec, convertTo()-
312*/-
313-
314-
315/*!-
316 \fn QColor::QColor()-
317-
318 Constructs an invalid color with the RGB value (0, 0, 0). An-
319 invalid color is a color that is not properly set up for the-
320 underlying window system.-
321-
322 The alpha value of an invalid color is unspecified.-
323-
324 \sa isValid()-
325*/-
326-
327/*!-
328 \overload-
329-
330 Constructs a new color with a color value of \a color.-
331-
332 \sa isValid(), {QColor#Predefined Colors}{Predefined Colors}-
333 */-
334QColor::QColor(Qt::GlobalColor color)-
335{-
336#define QRGB(r, g, b) \-
337 QRgb(((0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))-
338#define QRGBA(r, g, b, a) \-
339 QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))-
340-
341 static const QRgb global_colors[] = {-
342 QRGB(255, 255, 255), // Qt::color0-
343 QRGB( 0, 0, 0), // Qt::color1-
344 QRGB( 0, 0, 0), // black-
345 QRGB(255, 255, 255), // white-
346 /*-
347 * From the "The Palette Manager: How and Why" by Ron Gery,-
348 * March 23, 1992, archived on MSDN:-
349 *-
350 * The Windows system palette is broken up into two-
351 * sections, one with fixed colors and one with colors-
352 * that can be changed by applications. The system palette-
353 * predefines 20 entries; these colors are known as the-
354 * static or reserved colors and consist of the 16 colors-
355 * found in the Windows version 3.0 VGA driver and 4-
356 * additional colors chosen for their visual appeal. The-
357 * DEFAULT_PALETTE stock object is, as the name implies,-
358 * the default palette selected into a device context (DC)-
359 * and consists of these static colors. Applications can-
360 * set the remaining 236 colors using the Palette Manager.-
361 *-
362 * The 20 reserved entries have indices in [0,9] and-
363 * [246,255]. We reuse 17 of them.-
364 */-
365 QRGB(128, 128, 128), // index 248 medium gray-
366 QRGB(160, 160, 164), // index 247 light gray-
367 QRGB(192, 192, 192), // index 7 light gray-
368 QRGB(255, 0, 0), // index 249 red-
369 QRGB( 0, 255, 0), // index 250 green-
370 QRGB( 0, 0, 255), // index 252 blue-
371 QRGB( 0, 255, 255), // index 254 cyan-
372 QRGB(255, 0, 255), // index 253 magenta-
373 QRGB(255, 255, 0), // index 251 yellow-
374 QRGB(128, 0, 0), // index 1 dark red-
375 QRGB( 0, 128, 0), // index 2 dark green-
376 QRGB( 0, 0, 128), // index 4 dark blue-
377 QRGB( 0, 128, 128), // index 6 dark cyan-
378 QRGB(128, 0, 128), // index 5 dark magenta-
379 QRGB(128, 128, 0), // index 3 dark yellow-
380 QRGBA(0, 0, 0, 0) // transparent-
381 };-
382#undef QRGB-
383#undef QRGBA-
384-
385 setRgb(qRed(global_colors[color]),-
386 qGreen(global_colors[color]),-
387 qBlue(global_colors[color]),-
388 qAlpha(global_colors[color]));-
389}
never executed: end of block
0
390-
391/*!-
392 \fn QColor::QColor(int r, int g, int b, int a = 255)-
393-
394 Constructs a color with the RGB value \a r, \a g, \a b, and the-
395 alpha-channel (transparency) value of \a a.-
396-
397 The color is left invalid if any of the arguments are invalid.-
398-
399 \sa setRgba(), isValid()-
400*/-
401-
402/*!-
403 Constructs a color with the value \a color. The alpha component is-
404 ignored and set to solid.-
405-
406 \sa fromRgb(), isValid()-
407*/-
408-
409QColor::QColor(QRgb color)-
410{-
411 cspec = Rgb;-
412 ct.argb.alpha = 0xffff;-
413 ct.argb.red = qRed(color) * 0x101;-
414 ct.argb.green = qGreen(color) * 0x101;-
415 ct.argb.blue = qBlue(color) * 0x101;-
416 ct.argb.pad = 0;-
417}
never executed: end of block
0
418-
419/*!-
420 \since 5.6-
421-
422 Constructs a color with the value \a rgba64.-
423-
424 \sa fromRgba64()-
425*/-
426-
427QColor::QColor(QRgba64 rgba64)-
428{-
429 setRgba64(rgba64);-
430}
never executed: end of block
0
431-
432/*!-
433 \internal-
434-
435 Constructs a color with the given \a spec.-
436-
437 This function is primarly present to avoid that QColor::Invalid-
438 becomes a valid color by accident.-
439*/-
440-
441QColor::QColor(Spec spec)-
442{-
443 switch (spec) {-
444 case Invalid:
never executed: case Invalid:
0
445 invalidate();-
446 break;
never executed: break;
0
447 case Rgb:
never executed: case Rgb:
0
448 setRgb(0, 0, 0);-
449 break;
never executed: break;
0
450 case Hsv:
never executed: case Hsv:
0
451 setHsv(0, 0, 0);-
452 break;
never executed: break;
0
453 case Cmyk:
never executed: case Cmyk:
0
454 setCmyk(0, 0, 0, 0);-
455 break;
never executed: break;
0
456 case Hsl:
never executed: case Hsl:
0
457 setHsl(0, 0, 0, 0);-
458 break;
never executed: break;
0
459 }-
460}
never executed: end of block
0
461-
462/*!-
463 \fn QColor::QColor(const QString &name)-
464-
465 Constructs a named color in the same way as setNamedColor() using-
466 the given \a name.-
467-
468 The color is left invalid if the \a name cannot be parsed.-
469-
470 \sa setNamedColor(), name(), isValid()-
471*/-
472-
473/*!-
474 \fn QColor::QColor(const char *name)-
475-
476 Constructs a named color in the same way as setNamedColor() using-
477 the given \a name.-
478-
479 The color is left invalid if the \a name cannot be parsed.-
480-
481 \sa setNamedColor(), name(), isValid()-
482*/-
483-
484#if QT_VERSION < QT_VERSION_CHECK(6,0,0)-
485/*!-
486 \fn QColor::QColor(const QColor &color)-
487-
488 Constructs a color that is a copy of \a color.-
489-
490 \sa isValid()-
491*/-
492#endif-
493-
494/*!-
495 \fn bool QColor::isValid() const-
496-
497 Returns \c true if the color is valid; otherwise returns \c false.-
498*/-
499-
500/*!-
501 Returns the name of the color in the format "#RRGGBB"; i.e. a "#"-
502 character followed by three two-digit hexadecimal numbers.-
503-
504 \sa setNamedColor()-
505*/-
506-
507QString QColor::name() const-
508{-
509 return name(HexRgb);
never executed: return name(HexRgb);
0
510}-
511-
512/*!-
513 \since 5.2-
514-
515 Returns the name of the color in the specified \a format.-
516-
517 \sa setNamedColor(), NameFormat-
518*/-
519-
520QString QColor::name(NameFormat format) const-
521{-
522 switch (format) {-
523 case HexRgb:
never executed: case HexRgb:
0
524 return QLatin1Char('#') + QString::number(rgba() | 0x1000000, 16).rightRef(6);
never executed: return QLatin1Char('#') + QString::number(rgba() | 0x1000000, 16).rightRef(6);
0
525 case HexArgb:
never executed: case HexArgb:
0
526 // it's called rgba() but it does return AARRGGBB-
527 return QLatin1Char('#') + QString::number(rgba() | 0x100000000, 16).rightRef(8);
never executed: return QLatin1Char('#') + QString::number(rgba() | 0x100000000, 16).rightRef(8);
0
528 }-
529 return QString();
never executed: return QString();
0
530}-
531-
532/*!-
533 Sets the RGB value of this QColor to \a name, which may be in one-
534 of these formats:-
535-
536 \list-
537 \li #RGB (each of R, G, and B is a single hex digit)-
538 \li #RRGGBB-
539 \li #AARRGGBB (Since 5.2)-
540 \li #RRRGGGBBB-
541 \li #RRRRGGGGBBBB-
542 \li A name from the list of colors defined in the list of \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword names}-
543 provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro".-
544 These color names work on all platforms. Note that these color names are \e not the-
545 same as defined by the Qt::GlobalColor enums, e.g. "green" and Qt::green does not-
546 refer to the same color.-
547 \li \c transparent - representing the absence of a color.-
548 \endlist-
549-
550 The color is invalid if \a name cannot be parsed.-
551-
552 \sa QColor(), name(), isValid()-
553*/-
554-
555void QColor::setNamedColor(const QString &name)-
556{-
557 setColorFromString(name);-
558}
never executed: end of block
0
559-
560/*!-
561 \since 4.7-
562-
563 Returns \c true if the \a name is a valid color name and can-
564 be used to construct a valid QColor object, otherwise returns-
565 false.-
566-
567 It uses the same algorithm used in setNamedColor().-
568-
569 \sa setNamedColor()-
570*/-
571bool QColor::isValidColor(const QString &name)-
572{-
573 return !name.isEmpty() && QColor().setColorFromString(name);
never executed: return !name.isEmpty() && QColor().setColorFromString(name);
!name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
QColor().setCo...omString(name)Description
TRUEnever evaluated
FALSEnever evaluated
0
574}-
575-
576bool QColor::setColorFromString(const QString &name)-
577{-
578 if (name.isEmpty()) {
name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
579 invalidate();-
580 return true;
never executed: return true;
0
581 }-
582-
583 if (name.startsWith(QLatin1Char('#'))) {
name.startsWit...tin1Char('#'))Description
TRUEnever evaluated
FALSEnever evaluated
0
584 QRgb rgba;-
585 if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) {
qt_get_hex_rgb...ngth(), &rgba)Description
TRUEnever evaluated
FALSEnever evaluated
0
586 setRgba(rgba);-
587 return true;
never executed: return true;
0
588 } else {-
589 invalidate();-
590 return false;
never executed: return false;
0
591 }-
592 }-
593-
594#ifndef QT_NO_COLORNAMES-
595 QRgb rgb;-
596 if (qt_get_named_rgb(name.constData(), name.length(), &rgb)) {
qt_get_named_r...ength(), &rgb)Description
TRUEnever evaluated
FALSEnever evaluated
0
597 setRgba(rgb);-
598 return true;
never executed: return true;
0
599 } else-
600#endif-
601 {-
602 invalidate();-
603 return false;
never executed: return false;
0
604 }-
605}-
606-
607/*!-
608 Returns a QStringList containing the color names Qt knows about.-
609-
610 \sa {QColor#Predefined Colors}{Predefined Colors}-
611*/-
612QStringList QColor::colorNames()-
613{-
614#ifndef QT_NO_COLORNAMES-
615 return qt_get_colornames();
never executed: return qt_get_colornames();
0
616#else-
617 return QStringList();-
618#endif-
619}-
620-
621/*!-
622 Sets the contents pointed to by \a h, \a s, \a v, and \a a, to the hue,-
623 saturation, value, and alpha-channel (transparency) components of the-
624 color's HSV value.-
625-
626 These components can be retrieved individually using the hueF(),-
627 saturationF(), valueF() and alphaF() functions.-
628-
629 \sa setHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
630*/-
631void QColor::getHsvF(qreal *h, qreal *s, qreal *v, qreal *a) const-
632{-
633 if (!h || !s || !v)
!hDescription
TRUEnever evaluated
FALSEnever evaluated
!sDescription
TRUEnever evaluated
FALSEnever evaluated
!vDescription
TRUEnever evaluated
FALSEnever evaluated
0
634 return;
never executed: return;
0
635-
636 if (cspec != Invalid && cspec != Hsv) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
637 toHsv().getHsvF(h, s, v, a);-
638 return;
never executed: return;
0
639 }-
640-
641 *h = ct.ahsv.hue == USHRT_MAX ? qreal(-1.0) : ct.ahsv.hue / qreal(36000.0);
ct.ahsv.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
642 *s = ct.ahsv.saturation / qreal(USHRT_MAX);-
643 *v = ct.ahsv.value / qreal(USHRT_MAX);-
644-
645 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
646 *a = ct.ahsv.alpha / qreal(USHRT_MAX);
never executed: *a = ct.ahsv.alpha / qreal((32767 * 2 + 1));
0
647}
never executed: end of block
0
648-
649/*!-
650 Sets the contents pointed to by \a h, \a s, \a v, and \a a, to the hue,-
651 saturation, value, and alpha-channel (transparency) components of the-
652 color's HSV value.-
653-
654 These components can be retrieved individually using the hue(),-
655 saturation(), value() and alpha() functions.-
656-
657 \sa setHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
658*/-
659void QColor::getHsv(int *h, int *s, int *v, int *a) const-
660{-
661 if (!h || !s || !v)
!hDescription
TRUEnever evaluated
FALSEnever evaluated
!sDescription
TRUEnever evaluated
FALSEnever evaluated
!vDescription
TRUEnever evaluated
FALSEnever evaluated
0
662 return;
never executed: return;
0
663-
664 if (cspec != Invalid && cspec != Hsv) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
665 toHsv().getHsv(h, s, v, a);-
666 return;
never executed: return;
0
667 }-
668-
669 *h = ct.ahsv.hue == USHRT_MAX ? -1 : ct.ahsv.hue / 100;
ct.ahsv.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
670 *s = ct.ahsv.saturation >> 8;-
671 *v = ct.ahsv.value >> 8;-
672-
673 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
674 *a = ct.ahsv.alpha >> 8;
never executed: *a = ct.ahsv.alpha >> 8;
0
675}
never executed: end of block
0
676-
677/*!-
678 Sets a HSV color value; \a h is the hue, \a s is the saturation, \a v is-
679 the value and \a a is the alpha component of the HSV color.-
680-
681 All the values must be in the range 0.0-1.0.-
682-
683 \sa getHsvF(), setHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
684*/-
685void QColor::setHsvF(qreal h, qreal s, qreal v, qreal a)-
686{-
687 if (((h < qreal(0.0) || h > qreal(1.0)) && h != qreal(-1.0))
h < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
h > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
h != qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
688 || (s < qreal(0.0) || s > qreal(1.0))
s < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
s > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
689 || (v < qreal(0.0) || v > qreal(1.0))
v < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
v > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
690 || (a < qreal(0.0) || a > qreal(1.0))) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
691 qWarning("QColor::setHsvF: HSV parameters out of range");-
692 return;
never executed: return;
0
693 }-
694-
695 cspec = Hsv;-
696 ct.ahsv.alpha = qRound(a * USHRT_MAX);-
697 ct.ahsv.hue = h == qreal(-1.0) ? USHRT_MAX : qRound(h * 36000);
h == qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
698 ct.ahsv.saturation = qRound(s * USHRT_MAX);-
699 ct.ahsv.value = qRound(v * USHRT_MAX);-
700 ct.ahsv.pad = 0;-
701}
never executed: end of block
0
702-
703/*!-
704 Sets a HSV color value; \a h is the hue, \a s is the saturation, \a v is-
705 the value and \a a is the alpha component of the HSV color.-
706-
707 The saturation, value and alpha-channel values must be in the range 0-255,-
708 and the hue value must be greater than -1.-
709-
710 \sa getHsv(), setHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}-
711*/-
712void QColor::setHsv(int h, int s, int v, int a)-
713{-
714 if (h < -1 || (uint)s > 255 || (uint)v > 255 || (uint)a > 255) {
h < -1Description
TRUEnever evaluated
FALSEnever evaluated
(uint)s > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)v > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
715 qWarning("QColor::setHsv: HSV parameters out of range");-
716 invalidate();-
717 return;
never executed: return;
0
718 }-
719-
720 cspec = Hsv;-
721 ct.ahsv.alpha = a * 0x101;-
722 ct.ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
h == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
723 ct.ahsv.saturation = s * 0x101;-
724 ct.ahsv.value = v * 0x101;-
725 ct.ahsv.pad = 0;-
726}
never executed: end of block
0
727-
728/*!-
729 \since 4.6-
730-
731 Sets the contents pointed to by \a h, \a s, \a l, and \a a, to the hue,-
732 saturation, lightness, and alpha-channel (transparency) components of the-
733 color's HSL value.-
734-
735 These components can be retrieved individually using the hslHueF(),-
736 hslSaturationF(), lightnessF() and alphaF() functions.-
737-
738 \sa setHsl()-
739*/-
740void QColor::getHslF(qreal *h, qreal *s, qreal *l, qreal *a) const-
741{-
742 if (!h || !s || !l)
!hDescription
TRUEnever evaluated
FALSEnever evaluated
!sDescription
TRUEnever evaluated
FALSEnever evaluated
!lDescription
TRUEnever evaluated
FALSEnever evaluated
0
743 return;
never executed: return;
0
744-
745 if (cspec != Invalid && cspec != Hsl) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
746 toHsl().getHslF(h, s, l, a);-
747 return;
never executed: return;
0
748 }-
749-
750 *h = ct.ahsl.hue == USHRT_MAX ? qreal(-1.0) : ct.ahsl.hue / qreal(36000.0);
ct.ahsl.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
751 *s = ct.ahsl.saturation / qreal(USHRT_MAX);-
752 *l = ct.ahsl.lightness / qreal(USHRT_MAX);-
753-
754 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
755 *a = ct.ahsl.alpha / qreal(USHRT_MAX);
never executed: *a = ct.ahsl.alpha / qreal((32767 * 2 + 1));
0
756}
never executed: end of block
0
757-
758/*!-
759 \since 4.6-
760-
761 Sets the contents pointed to by \a h, \a s, \a l, and \a a, to the hue,-
762 saturation, lightness, and alpha-channel (transparency) components of the-
763 color's HSL value.-
764-
765 These components can be retrieved individually using the hslHue(),-
766 hslSaturation(), lightness() and alpha() functions.-
767-
768 \sa setHsl()-
769*/-
770void QColor::getHsl(int *h, int *s, int *l, int *a) const-
771{-
772 if (!h || !s || !l)
!hDescription
TRUEnever evaluated
FALSEnever evaluated
!sDescription
TRUEnever evaluated
FALSEnever evaluated
!lDescription
TRUEnever evaluated
FALSEnever evaluated
0
773 return;
never executed: return;
0
774-
775 if (cspec != Invalid && cspec != Hsl) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
776 toHsl().getHsl(h, s, l, a);-
777 return;
never executed: return;
0
778 }-
779-
780 *h = ct.ahsl.hue == USHRT_MAX ? -1 : ct.ahsl.hue / 100;
ct.ahsl.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
781 *s = ct.ahsl.saturation >> 8;-
782 *l = ct.ahsl.lightness >> 8;-
783-
784 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
785 *a = ct.ahsl.alpha >> 8;
never executed: *a = ct.ahsl.alpha >> 8;
0
786}
never executed: end of block
0
787-
788/*!-
789 \since 4.6-
790-
791 Sets a HSL color lightness; \a h is the hue, \a s is the saturation, \a l is-
792 the lightness and \a a is the alpha component of the HSL color.-
793-
794 All the values must be in the range 0.0-1.0.-
795-
796 \sa getHslF(), setHsl()-
797*/-
798void QColor::setHslF(qreal h, qreal s, qreal l, qreal a)-
799{-
800 if (((h < qreal(0.0) || h > qreal(1.0)) && h != qreal(-1.0))
h < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
h > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
h != qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
801 || (s < qreal(0.0) || s > qreal(1.0))
s < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
s > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
802 || (l < qreal(0.0) || l > qreal(1.0))
l < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
l > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
803 || (a < qreal(0.0) || a > qreal(1.0))) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
804 qWarning("QColor::setHsvF: HSV parameters out of range");-
805 return;
never executed: return;
0
806 }-
807-
808 cspec = Hsl;-
809 ct.ahsl.alpha = qRound(a * USHRT_MAX);-
810 ct.ahsl.hue = h == qreal(-1.0) ? USHRT_MAX : qRound(h * 36000);
h == qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
811 ct.ahsl.saturation = qRound(s * USHRT_MAX);-
812 ct.ahsl.lightness = qRound(l * USHRT_MAX);-
813 ct.ahsl.pad = 0;-
814}
never executed: end of block
0
815-
816/*!-
817 \since 4.6-
818-
819 Sets a HSL color value; \a h is the hue, \a s is the saturation, \a l is-
820 the lightness and \a a is the alpha component of the HSL color.-
821-
822 The saturation, value and alpha-channel values must be in the range 0-255,-
823 and the hue value must be greater than -1.-
824-
825 \sa getHsl(), setHslF()-
826*/-
827void QColor::setHsl(int h, int s, int l, int a)-
828{-
829 if (h < -1 || (uint)s > 255 || (uint)l > 255 || (uint)a > 255) {
h < -1Description
TRUEnever evaluated
FALSEnever evaluated
(uint)s > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)l > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
830 qWarning("QColor::setHsv: HSV parameters out of range");-
831 invalidate();-
832 return;
never executed: return;
0
833 }-
834-
835 cspec = Hsl;-
836 ct.ahsl.alpha = a * 0x101;-
837 ct.ahsl.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
h == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
838 ct.ahsl.saturation = s * 0x101;-
839 ct.ahsl.lightness = l * 0x101;-
840 ct.ahsl.pad = 0;-
841}
never executed: end of block
0
842-
843/*!-
844 Sets the contents pointed to by \a r, \a g, \a b, and \a a, to the red,-
845 green, blue, and alpha-channel (transparency) components of the color's-
846 RGB value.-
847-
848 These components can be retrieved individually using the redF(), greenF(),-
849 blueF() and alphaF() functions.-
850-
851 \sa rgb(), setRgb()-
852*/-
853void QColor::getRgbF(qreal *r, qreal *g, qreal *b, qreal *a) const-
854{-
855 if (!r || !g || !b)
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!gDescription
TRUEnever evaluated
FALSEnever evaluated
!bDescription
TRUEnever evaluated
FALSEnever evaluated
0
856 return;
never executed: return;
0
857-
858 if (cspec != Invalid && cspec != Rgb) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
859 toRgb().getRgbF(r, g, b, a);-
860 return;
never executed: return;
0
861 }-
862-
863 *r = ct.argb.red / qreal(USHRT_MAX);-
864 *g = ct.argb.green / qreal(USHRT_MAX);-
865 *b = ct.argb.blue / qreal(USHRT_MAX);-
866-
867 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
868 *a = ct.argb.alpha / qreal(USHRT_MAX);
never executed: *a = ct.argb.alpha / qreal((32767 * 2 + 1));
0
869-
870}
never executed: end of block
0
871-
872/*!-
873 Sets the contents pointed to by \a r, \a g, \a b, and \a a, to the red,-
874 green, blue, and alpha-channel (transparency) components of the color's-
875 RGB value.-
876-
877 These components can be retrieved individually using the red(), green(),-
878 blue() and alpha() functions.-
879-
880 \sa rgb(), setRgb()-
881*/-
882void QColor::getRgb(int *r, int *g, int *b, int *a) const-
883{-
884 if (!r || !g || !b)
!rDescription
TRUEnever evaluated
FALSEnever evaluated
!gDescription
TRUEnever evaluated
FALSEnever evaluated
!bDescription
TRUEnever evaluated
FALSEnever evaluated
0
885 return;
never executed: return;
0
886-
887 if (cspec != Invalid && cspec != Rgb) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
888 toRgb().getRgb(r, g, b, a);-
889 return;
never executed: return;
0
890 }-
891-
892 *r = ct.argb.red >> 8;-
893 *g = ct.argb.green >> 8;-
894 *b = ct.argb.blue >> 8;-
895-
896 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
897 *a = ct.argb.alpha >> 8;
never executed: *a = ct.argb.alpha >> 8;
0
898}
never executed: end of block
0
899-
900/*!-
901 \fn void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a)-
902-
903 Sets the color channels of this color to \a r (red), \a g (green),-
904 \a b (blue) and \a a (alpha, transparency).-
905-
906 All values must be in the range 0.0-1.0.-
907-
908 \sa rgb(), getRgbF(), setRgb()-
909*/-
910void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a)-
911{-
912 if (r < qreal(0.0) || r > qreal(1.0)
r < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
r > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
913 || g < qreal(0.0) || g > qreal(1.0)
g < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
g > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
914 || b < qreal(0.0) || b > qreal(1.0)
b < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
b > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
915 || a < qreal(0.0) || a > qreal(1.0)) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
916 qWarning("QColor::setRgbF: RGB parameters out of range");-
917 invalidate();-
918 return;
never executed: return;
0
919 }-
920-
921 cspec = Rgb;-
922 ct.argb.alpha = qRound(a * USHRT_MAX);-
923 ct.argb.red = qRound(r * USHRT_MAX);-
924 ct.argb.green = qRound(g * USHRT_MAX);-
925 ct.argb.blue = qRound(b * USHRT_MAX);-
926 ct.argb.pad = 0;-
927}
never executed: end of block
0
928-
929/*!-
930 Sets the RGB value to \a r, \a g, \a b and the alpha value to \a a.-
931-
932 All the values must be in the range 0-255.-
933-
934 \sa rgb(), getRgb(), setRgbF()-
935*/-
936void QColor::setRgb(int r, int g, int b, int a)-
937{-
938 if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
(uint)r > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)g > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)b > 255Description
TRUEnever evaluated
FALSEnever evaluated
(uint)a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
939 qWarning("QColor::setRgb: RGB parameters out of range");-
940 invalidate();-
941 return;
never executed: return;
0
942 }-
943-
944 cspec = Rgb;-
945 ct.argb.alpha = a * 0x101;-
946 ct.argb.red = r * 0x101;-
947 ct.argb.green = g * 0x101;-
948 ct.argb.blue = b * 0x101;-
949 ct.argb.pad = 0;-
950}
never executed: end of block
0
951-
952/*!-
953 \fn QRgb QColor::rgba() const-
954-
955 Returns the RGB value of the color, including its alpha.-
956-
957 For an invalid color, the alpha value of the returned color is unspecified.-
958-
959 \sa setRgba(), rgb(), rgba64()-
960*/-
961-
962QRgb QColor::rgba() const-
963{-
964 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
965 return toRgb().rgba();
never executed: return toRgb().rgba();
0
966 return qRgba(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8, ct.argb.alpha >> 8);
never executed: return qRgba(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8, ct.argb.alpha >> 8);
0
967}-
968-
969/*!-
970 Sets the RGB value to \a rgba, including its alpha.-
971-
972 \sa rgba(), rgb(), setRgba64()-
973*/-
974void QColor::setRgba(QRgb rgba)-
975{-
976 cspec = Rgb;-
977 ct.argb.alpha = qAlpha(rgba) * 0x101;-
978 ct.argb.red = qRed(rgba) * 0x101;-
979 ct.argb.green = qGreen(rgba) * 0x101;-
980 ct.argb.blue = qBlue(rgba) * 0x101;-
981 ct.argb.pad = 0;-
982}
never executed: end of block
0
983-
984/*!-
985 \since 5.6-
986-
987 Returns the RGB64 value of the color, including its alpha.-
988-
989 For an invalid color, the alpha value of the returned color is unspecified.-
990-
991 \sa setRgba64(), rgba(), rgb()-
992*/-
993-
994QRgba64 QColor::rgba64() const-
995{-
996 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
997 return toRgb().rgba64();
never executed: return toRgb().rgba64();
0
998 return qRgba64(ct.argb.red, ct.argb.green, ct.argb.blue, ct.argb.alpha);
never executed: return qRgba64(ct.argb.red, ct.argb.green, ct.argb.blue, ct.argb.alpha);
0
999}-
1000-
1001/*!-
1002 \since 5.6-
1003-
1004 Sets the RGB64 value to \a rgba, including its alpha.-
1005-
1006 \sa \setRgba(), rgba64()-
1007*/-
1008void QColor::setRgba64(QRgba64 rgba)-
1009{-
1010 cspec = Rgb;-
1011 ct.argb.alpha = rgba.alpha();-
1012 ct.argb.red = rgba.red();-
1013 ct.argb.green = rgba.green();-
1014 ct.argb.blue = rgba.blue();-
1015 ct.argb.pad = 0;-
1016}
never executed: end of block
0
1017-
1018/*!-
1019 \fn QRgb QColor::rgb() const-
1020-
1021 Returns the RGB value of the color. The alpha value is opaque.-
1022-
1023 \sa getRgb(), rgba()-
1024*/-
1025QRgb QColor::rgb() const-
1026{-
1027 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1028 return toRgb().rgb();
never executed: return toRgb().rgb();
0
1029 return qRgb(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8);
never executed: return qRgb(ct.argb.red >> 8, ct.argb.green >> 8, ct.argb.blue >> 8);
0
1030}-
1031-
1032/*!-
1033 \overload-
1034-
1035 Sets the RGB value to \a rgb. The alpha value is set to opaque.-
1036*/-
1037void QColor::setRgb(QRgb rgb)-
1038{-
1039 cspec = Rgb;-
1040 ct.argb.alpha = 0xffff;-
1041 ct.argb.red = qRed(rgb) * 0x101;-
1042 ct.argb.green = qGreen(rgb) * 0x101;-
1043 ct.argb.blue = qBlue(rgb) * 0x101;-
1044 ct.argb.pad = 0;-
1045}
never executed: end of block
0
1046-
1047/*!-
1048 Returns the alpha color component of this color.-
1049-
1050 \sa setAlpha(), alphaF(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}-
1051*/-
1052int QColor::alpha() const-
1053{
never executed: return ct.argb.alpha >> 8;
return ct.argb.alpha >> 8; }
never executed: return ct.argb.alpha >> 8;
0
1054-
1055-
1056/*!-
1057 Sets the alpha of this color to \a alpha. Integer alpha is specified in the-
1058 range 0-255.-
1059-
1060 \sa alpha(), alphaF(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}-
1061*/-
1062-
1063void QColor::setAlpha(int alpha)-
1064{-
1065 QCOLOR_INT_RANGE_CHECK("QColor::setAlpha", alpha);
never executed: end of block
alpha < 0Description
TRUEnever evaluated
FALSEnever evaluated
alpha > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1066 ct.argb.alpha = alpha * 0x101;-
1067}
never executed: end of block
0
1068-
1069/*!-
1070 Returns the alpha color component of this color.-
1071-
1072 \sa setAlphaF(), alpha(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}-
1073*/-
1074qreal QColor::alphaF() const-
1075{
never executed: return ct.argb.alpha / qreal((32767 * 2 + 1));
return ct.argb.alpha / qreal(USHRT_MAX); }
never executed: return ct.argb.alpha / qreal((32767 * 2 + 1));
0
1076-
1077/*!-
1078 Sets the alpha of this color to \a alpha. qreal alpha is specified in the-
1079 range 0.0-1.0.-
1080-
1081 \sa alphaF(), alpha(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}-
1082-
1083*/-
1084void QColor::setAlphaF(qreal alpha)-
1085{-
1086 QCOLOR_REAL_RANGE_CHECK("QColor::setAlphaF", alpha);
never executed: end of block
alpha < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
alpha > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1087 qreal tmp = alpha * USHRT_MAX;-
1088 ct.argb.alpha = qRound(tmp);-
1089}
never executed: end of block
0
1090-
1091-
1092/*!-
1093 Returns the red color component of this color.-
1094-
1095 \sa setRed(), redF(), getRgb()-
1096*/-
1097int QColor::red() const-
1098{-
1099 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1100 return toRgb().red();
never executed: return toRgb().red();
0
1101 return ct.argb.red >> 8;
never executed: return ct.argb.red >> 8;
0
1102}-
1103-
1104/*!-
1105 Sets the red color component of this color to \a red. Integer components-
1106 are specified in the range 0-255.-
1107-
1108 \sa red(), redF(), setRgb()-
1109*/-
1110void QColor::setRed(int red)-
1111{-
1112 QCOLOR_INT_RANGE_CHECK("QColor::setRed", red);
never executed: end of block
red < 0Description
TRUEnever evaluated
FALSEnever evaluated
red > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1113 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1114 setRgb(red, green(), blue(), alpha());
never executed: setRgb(red, green(), blue(), alpha());
0
1115 else-
1116 ct.argb.red = red * 0x101;
never executed: ct.argb.red = red * 0x101;
0
1117}-
1118-
1119/*!-
1120 Returns the green color component of this color.-
1121-
1122 \sa setGreen(), greenF(), getRgb()-
1123*/-
1124int QColor::green() const-
1125{-
1126 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1127 return toRgb().green();
never executed: return toRgb().green();
0
1128 return ct.argb.green >> 8;
never executed: return ct.argb.green >> 8;
0
1129}-
1130-
1131/*!-
1132 Sets the green color component of this color to \a green. Integer-
1133 components are specified in the range 0-255.-
1134-
1135 \sa green(), greenF(), setRgb()-
1136*/-
1137void QColor::setGreen(int green)-
1138{-
1139 QCOLOR_INT_RANGE_CHECK("QColor::setGreen", green);
never executed: end of block
green < 0Description
TRUEnever evaluated
FALSEnever evaluated
green > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1140 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1141 setRgb(red(), green, blue(), alpha());
never executed: setRgb(red(), green, blue(), alpha());
0
1142 else-
1143 ct.argb.green = green * 0x101;
never executed: ct.argb.green = green * 0x101;
0
1144}-
1145-
1146-
1147/*!-
1148 Returns the blue color component of this color.-
1149-
1150 \sa setBlue(), blueF(), getRgb()-
1151*/-
1152int QColor::blue() const-
1153{-
1154 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1155 return toRgb().blue();
never executed: return toRgb().blue();
0
1156 return ct.argb.blue >> 8;
never executed: return ct.argb.blue >> 8;
0
1157}-
1158-
1159-
1160/*!-
1161 Sets the blue color component of this color to \a blue. Integer components-
1162 are specified in the range 0-255.-
1163-
1164 \sa blue(), blueF(), setRgb()-
1165*/-
1166void QColor::setBlue(int blue)-
1167{-
1168 QCOLOR_INT_RANGE_CHECK("QColor::setBlue", blue);
never executed: end of block
blue < 0Description
TRUEnever evaluated
FALSEnever evaluated
blue > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1169 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1170 setRgb(red(), green(), blue, alpha());
never executed: setRgb(red(), green(), blue, alpha());
0
1171 else-
1172 ct.argb.blue = blue * 0x101;
never executed: ct.argb.blue = blue * 0x101;
0
1173}-
1174-
1175/*!-
1176 Returns the red color component of this color.-
1177-
1178 \sa setRedF(), red(), getRgbF()-
1179*/-
1180qreal QColor::redF() const-
1181{-
1182 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1183 return toRgb().redF();
never executed: return toRgb().redF();
0
1184 return ct.argb.red / qreal(USHRT_MAX);
never executed: return ct.argb.red / qreal((32767 * 2 + 1));
0
1185}-
1186-
1187-
1188/*!-
1189 Sets the red color component of this color to \a red. Float components-
1190 are specified in the range 0.0-1.0.-
1191-
1192 \sa redF(), red(), setRgbF()-
1193*/-
1194void QColor::setRedF(qreal red)-
1195{-
1196 QCOLOR_REAL_RANGE_CHECK("QColor::setRedF", red);
never executed: end of block
red < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
red > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1197 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1198 setRgbF(red, greenF(), blueF(), alphaF());
never executed: setRgbF(red, greenF(), blueF(), alphaF());
0
1199 else-
1200 ct.argb.red = qRound(red * USHRT_MAX);
never executed: ct.argb.red = qRound(red * (32767 * 2 + 1));
0
1201}-
1202-
1203/*!-
1204 Returns the green color component of this color.-
1205-
1206 \sa setGreenF(), green(), getRgbF()-
1207*/-
1208qreal QColor::greenF() const-
1209{-
1210 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1211 return toRgb().greenF();
never executed: return toRgb().greenF();
0
1212 return ct.argb.green / qreal(USHRT_MAX);
never executed: return ct.argb.green / qreal((32767 * 2 + 1));
0
1213}-
1214-
1215-
1216/*!-
1217 Sets the green color component of this color to \a green. Float components-
1218 are specified in the range 0.0-1.0.-
1219-
1220 \sa greenF(), green(), setRgbF()-
1221*/-
1222void QColor::setGreenF(qreal green)-
1223{-
1224 QCOLOR_REAL_RANGE_CHECK("QColor::setGreenF", green);
never executed: end of block
green < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
green > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1225 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1226 setRgbF(redF(), green, blueF(), alphaF());
never executed: setRgbF(redF(), green, blueF(), alphaF());
0
1227 else-
1228 ct.argb.green = qRound(green * USHRT_MAX);
never executed: ct.argb.green = qRound(green * (32767 * 2 + 1));
0
1229}-
1230-
1231/*!-
1232 Returns the blue color component of this color.-
1233-
1234 \sa setBlueF(), blue(), getRgbF()-
1235*/-
1236qreal QColor::blueF() const-
1237{-
1238 if (cspec != Invalid && cspec != Rgb)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1239 return toRgb().blueF();
never executed: return toRgb().blueF();
0
1240 return ct.argb.blue / qreal(USHRT_MAX);
never executed: return ct.argb.blue / qreal((32767 * 2 + 1));
0
1241}-
1242-
1243/*!-
1244 Sets the blue color component of this color to \a blue. Float components-
1245 are specified in the range 0.0-1.0.-
1246-
1247 \sa blueF(), blue(), setRgbF()-
1248*/-
1249void QColor::setBlueF(qreal blue)-
1250{-
1251 QCOLOR_REAL_RANGE_CHECK("QColor::setBlueF", blue);
never executed: end of block
blue < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
blue > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1252 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1253 setRgbF(redF(), greenF(), blue, alphaF());
never executed: setRgbF(redF(), greenF(), blue, alphaF());
0
1254 else-
1255 ct.argb.blue = qRound(blue * USHRT_MAX);
never executed: ct.argb.blue = qRound(blue * (32767 * 2 + 1));
0
1256}-
1257-
1258/*!-
1259 Returns the hue color component of this color.-
1260-
1261 The color is implicitly converted to HSV.-
1262-
1263 \sa hsvHue(), hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
1264*/-
1265-
1266int QColor::hue() const-
1267{-
1268 return hsvHue();
never executed: return hsvHue();
0
1269}-
1270-
1271/*!-
1272 Returns the hue color component of this color.-
1273-
1274 \sa hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
1275*/-
1276int QColor::hsvHue() const-
1277{-
1278 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1279 return toHsv().hue();
never executed: return toHsv().hue();
0
1280 return ct.ahsv.hue == USHRT_MAX ? -1 : ct.ahsv.hue / 100;
never executed: return ct.ahsv.hue == (32767 * 2 + 1) ? -1 : ct.ahsv.hue / 100;
ct.ahsv.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1281}-
1282-
1283/*!-
1284 Returns the saturation color component of this color.-
1285-
1286 The color is implicitly converted to HSV.-
1287-
1288 \sa hsvSaturation(), saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color-
1289 Model}-
1290*/-
1291-
1292int QColor::saturation() const-
1293{-
1294 return hsvSaturation();
never executed: return hsvSaturation();
0
1295}-
1296-
1297/*!-
1298 Returns the saturation color component of this color.-
1299-
1300 \sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
1301*/-
1302int QColor::hsvSaturation() const-
1303{-
1304 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1305 return toHsv().saturation();
never executed: return toHsv().saturation();
0
1306 return ct.ahsv.saturation >> 8;
never executed: return ct.ahsv.saturation >> 8;
0
1307}-
1308-
1309/*!-
1310 Returns the value color component of this color.-
1311-
1312 \sa valueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
1313*/-
1314int QColor::value() const-
1315{-
1316 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1317 return toHsv().value();
never executed: return toHsv().value();
0
1318 return ct.ahsv.value >> 8;
never executed: return ct.ahsv.value >> 8;
0
1319}-
1320-
1321/*!-
1322 Returns the hue color component of this color.-
1323-
1324 The color is implicitly converted to HSV.-
1325-
1326 \sa hsvHueF(), hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}-
1327*/-
1328qreal QColor::hueF() const-
1329{-
1330 return hsvHueF();
never executed: return hsvHueF();
0
1331}-
1332-
1333/*!-
1334 Returns the hue color component of this color.-
1335-
1336 \sa hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color-
1337 Model}-
1338*/-
1339qreal QColor::hsvHueF() const-
1340{-
1341 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1342 return toHsv().hueF();
never executed: return toHsv().hueF();
0
1343 return ct.ahsv.hue == USHRT_MAX ? qreal(-1.0) : ct.ahsv.hue / qreal(36000.0);
never executed: return ct.ahsv.hue == (32767 * 2 + 1) ? qreal(-1.0) : ct.ahsv.hue / qreal(36000.0);
ct.ahsv.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1344}-
1345-
1346/*!-
1347 Returns the saturation color component of this color.-
1348-
1349 The color is implicitly converted to HSV.-
1350-
1351 \sa hsvSaturationF(), saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color-
1352 Model}-
1353*/-
1354qreal QColor::saturationF() const-
1355{-
1356 return hsvSaturationF();
never executed: return hsvSaturationF();
0
1357}-
1358-
1359/*!-
1360 Returns the saturation color component of this color.-
1361-
1362 \sa saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}-
1363*/-
1364qreal QColor::hsvSaturationF() const-
1365{-
1366 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1367 return toHsv().saturationF();
never executed: return toHsv().saturationF();
0
1368 return ct.ahsv.saturation / qreal(USHRT_MAX);
never executed: return ct.ahsv.saturation / qreal((32767 * 2 + 1));
0
1369}-
1370-
1371/*!-
1372 Returns the value color component of this color.-
1373-
1374 \sa value(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}-
1375*/-
1376qreal QColor::valueF() const-
1377{-
1378 if (cspec != Invalid && cspec != Hsv)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1379 return toHsv().valueF();
never executed: return toHsv().valueF();
0
1380 return ct.ahsv.value / qreal(USHRT_MAX);
never executed: return ct.ahsv.value / qreal((32767 * 2 + 1));
0
1381}-
1382-
1383/*!-
1384 \since 4.6-
1385-
1386 Returns the hue color component of this color.-
1387-
1388 \sa getHslF(), getHsl()-
1389*/-
1390int QColor::hslHue() const-
1391{-
1392 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1393 return toHsl().hslHue();
never executed: return toHsl().hslHue();
0
1394 return ct.ahsl.hue == USHRT_MAX ? -1 : ct.ahsl.hue / 100;
never executed: return ct.ahsl.hue == (32767 * 2 + 1) ? -1 : ct.ahsl.hue / 100;
ct.ahsl.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1395}-
1396-
1397/*!-
1398 \since 4.6-
1399-
1400 Returns the saturation color component of this color.-
1401-
1402 \sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}-
1403*/-
1404int QColor::hslSaturation() const-
1405{-
1406 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1407 return toHsl().hslSaturation();
never executed: return toHsl().hslSaturation();
0
1408 return ct.ahsl.saturation >> 8;
never executed: return ct.ahsl.saturation >> 8;
0
1409}-
1410-
1411/*!-
1412 \since 4.6-
1413-
1414 Returns the lightness color component of this color.-
1415-
1416 \sa lightnessF(), getHsl()-
1417*/-
1418int QColor::lightness() const-
1419{-
1420 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1421 return toHsl().lightness();
never executed: return toHsl().lightness();
0
1422 return ct.ahsl.lightness >> 8;
never executed: return ct.ahsl.lightness >> 8;
0
1423}-
1424-
1425/*!-
1426 \since 4.6-
1427-
1428 Returns the hue color component of this color.-
1429-
1430 \sa hue(), getHslF()-
1431*/-
1432qreal QColor::hslHueF() const-
1433{-
1434 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1435 return toHsl().hslHueF();
never executed: return toHsl().hslHueF();
0
1436 return ct.ahsl.hue == USHRT_MAX ? qreal(-1.0) : ct.ahsl.hue / qreal(36000.0);
never executed: return ct.ahsl.hue == (32767 * 2 + 1) ? qreal(-1.0) : ct.ahsl.hue / qreal(36000.0);
ct.ahsl.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1437}-
1438-
1439/*!-
1440 \since 4.6-
1441-
1442 Returns the saturation color component of this color.-
1443-
1444 \sa saturationF(), getHslF()-
1445*/-
1446qreal QColor::hslSaturationF() const-
1447{-
1448 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1449 return toHsl().hslSaturationF();
never executed: return toHsl().hslSaturationF();
0
1450 return ct.ahsl.saturation / qreal(USHRT_MAX);
never executed: return ct.ahsl.saturation / qreal((32767 * 2 + 1));
0
1451}-
1452-
1453/*!-
1454 \since 4.6-
1455-
1456 Returns the lightness color component of this color.-
1457-
1458 \sa value(), getHslF()-
1459*/-
1460qreal QColor::lightnessF() const-
1461{-
1462 if (cspec != Invalid && cspec != Hsl)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1463 return toHsl().lightnessF();
never executed: return toHsl().lightnessF();
0
1464 return ct.ahsl.lightness / qreal(USHRT_MAX);
never executed: return ct.ahsl.lightness / qreal((32767 * 2 + 1));
0
1465}-
1466-
1467/*!-
1468 Returns the cyan color component of this color.-
1469-
1470 \sa cyanF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1471*/-
1472int QColor::cyan() const-
1473{-
1474 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1475 return toCmyk().cyan();
never executed: return toCmyk().cyan();
0
1476 return ct.acmyk.cyan >> 8;
never executed: return ct.acmyk.cyan >> 8;
0
1477}-
1478-
1479/*!-
1480 Returns the magenta color component of this color.-
1481-
1482 \sa magentaF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1483*/-
1484int QColor::magenta() const-
1485{-
1486 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1487 return toCmyk().magenta();
never executed: return toCmyk().magenta();
0
1488 return ct.acmyk.magenta >> 8;
never executed: return ct.acmyk.magenta >> 8;
0
1489}-
1490-
1491/*!-
1492 Returns the yellow color component of this color.-
1493-
1494 \sa yellowF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1495*/-
1496int QColor::yellow() const-
1497{-
1498 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1499 return toCmyk().yellow();
never executed: return toCmyk().yellow();
0
1500 return ct.acmyk.yellow >> 8;
never executed: return ct.acmyk.yellow >> 8;
0
1501}-
1502-
1503/*!-
1504 Returns the black color component of this color.-
1505-
1506 \sa blackF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1507-
1508*/-
1509int QColor::black() const-
1510{-
1511 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1512 return toCmyk().black();
never executed: return toCmyk().black();
0
1513 return ct.acmyk.black >> 8;
never executed: return ct.acmyk.black >> 8;
0
1514}-
1515-
1516/*!-
1517 Returns the cyan color component of this color.-
1518-
1519 \sa cyan(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1520*/-
1521qreal QColor::cyanF() const-
1522{-
1523 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1524 return toCmyk().cyanF();
never executed: return toCmyk().cyanF();
0
1525 return ct.acmyk.cyan / qreal(USHRT_MAX);
never executed: return ct.acmyk.cyan / qreal((32767 * 2 + 1));
0
1526}-
1527-
1528/*!-
1529 Returns the magenta color component of this color.-
1530-
1531 \sa magenta(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1532*/-
1533qreal QColor::magentaF() const-
1534{-
1535 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1536 return toCmyk().magentaF();
never executed: return toCmyk().magentaF();
0
1537 return ct.acmyk.magenta / qreal(USHRT_MAX);
never executed: return ct.acmyk.magenta / qreal((32767 * 2 + 1));
0
1538}-
1539-
1540/*!-
1541 Returns the yellow color component of this color.-
1542-
1543 \sa yellow(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1544*/-
1545qreal QColor::yellowF() const-
1546{-
1547 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1548 return toCmyk().yellowF();
never executed: return toCmyk().yellowF();
0
1549 return ct.acmyk.yellow / qreal(USHRT_MAX);
never executed: return ct.acmyk.yellow / qreal((32767 * 2 + 1));
0
1550}-
1551-
1552/*!-
1553 Returns the black color component of this color.-
1554-
1555 \sa black(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1556*/-
1557qreal QColor::blackF() const-
1558{-
1559 if (cspec != Invalid && cspec != Cmyk)
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1560 return toCmyk().blackF();
never executed: return toCmyk().blackF();
0
1561 return ct.acmyk.black / qreal(USHRT_MAX);
never executed: return ct.acmyk.black / qreal((32767 * 2 + 1));
0
1562}-
1563-
1564/*!-
1565 Create and returns an RGB QColor based on this color.-
1566-
1567 \sa fromRgb(), convertTo(), isValid()-
1568*/-
1569QColor QColor::toRgb() const-
1570{-
1571 if (!isValid() || cspec == Rgb)
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
cspec == RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1572 return *this;
never executed: return *this;
0
1573-
1574 QColor color;-
1575 color.cspec = Rgb;-
1576 color.ct.argb.alpha = ct.argb.alpha;-
1577 color.ct.argb.pad = 0;-
1578-
1579 switch (cspec) {-
1580 case Hsv:
never executed: case Hsv:
0
1581 {-
1582 if (ct.ahsv.saturation == 0 || ct.ahsv.hue == USHRT_MAX) {
ct.ahsv.saturation == 0Description
TRUEnever evaluated
FALSEnever evaluated
ct.ahsv.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1583 // achromatic case-
1584 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsv.value;-
1585 break;
never executed: break;
0
1586 }-
1587-
1588 // chromatic case-
1589 const qreal h = ct.ahsv.hue == 36000 ? 0 : ct.ahsv.hue / 6000.;
ct.ahsv.hue == 36000Description
TRUEnever evaluated
FALSEnever evaluated
0
1590 const qreal s = ct.ahsv.saturation / qreal(USHRT_MAX);-
1591 const qreal v = ct.ahsv.value / qreal(USHRT_MAX);-
1592 const int i = int(h);-
1593 const qreal f = h - i;-
1594 const qreal p = v * (qreal(1.0) - s);-
1595-
1596 if (i & 1) {
i & 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1597 const qreal q = v * (qreal(1.0) - (s * f));-
1598-
1599 switch (i) {-
1600 case 1:
never executed: case 1:
0
1601 color.ct.argb.red = qRound(q * USHRT_MAX);-
1602 color.ct.argb.green = qRound(v * USHRT_MAX);-
1603 color.ct.argb.blue = qRound(p * USHRT_MAX);-
1604 break;
never executed: break;
0
1605 case 3:
never executed: case 3:
0
1606 color.ct.argb.red = qRound(p * USHRT_MAX);-
1607 color.ct.argb.green = qRound(q * USHRT_MAX);-
1608 color.ct.argb.blue = qRound(v * USHRT_MAX);-
1609 break;
never executed: break;
0
1610 case 5:
never executed: case 5:
0
1611 color.ct.argb.red = qRound(v * USHRT_MAX);-
1612 color.ct.argb.green = qRound(p * USHRT_MAX);-
1613 color.ct.argb.blue = qRound(q * USHRT_MAX);-
1614 break;
never executed: break;
0
1615 }-
1616 } else {
never executed: end of block
0
1617 const qreal t = v * (qreal(1.0) - (s * (qreal(1.0) - f)));-
1618-
1619 switch (i) {-
1620 case 0:
never executed: case 0:
0
1621 color.ct.argb.red = qRound(v * USHRT_MAX);-
1622 color.ct.argb.green = qRound(t * USHRT_MAX);-
1623 color.ct.argb.blue = qRound(p * USHRT_MAX);-
1624 break;
never executed: break;
0
1625 case 2:
never executed: case 2:
0
1626 color.ct.argb.red = qRound(p * USHRT_MAX);-
1627 color.ct.argb.green = qRound(v * USHRT_MAX);-
1628 color.ct.argb.blue = qRound(t * USHRT_MAX);-
1629 break;
never executed: break;
0
1630 case 4:
never executed: case 4:
0
1631 color.ct.argb.red = qRound(t * USHRT_MAX);-
1632 color.ct.argb.green = qRound(p * USHRT_MAX);-
1633 color.ct.argb.blue = qRound(v * USHRT_MAX);-
1634 break;
never executed: break;
0
1635 }-
1636 }
never executed: end of block
0
1637 break;
never executed: break;
0
1638 }-
1639 case Hsl:
never executed: case Hsl:
0
1640 {-
1641 if (ct.ahsl.saturation == 0 || ct.ahsl.hue == USHRT_MAX) {
ct.ahsl.saturation == 0Description
TRUEnever evaluated
FALSEnever evaluated
ct.ahsl.hue == (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1642 // achromatic case-
1643 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = ct.ahsl.lightness;-
1644 } else if (ct.ahsl.lightness == 0) {
never executed: end of block
ct.ahsl.lightness == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1645 // lightness 0-
1646 color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = 0;-
1647 } else {
never executed: end of block
0
1648 // chromatic case-
1649 const qreal h = ct.ahsl.hue == 36000 ? 0 : ct.ahsl.hue / 36000.;
ct.ahsl.hue == 36000Description
TRUEnever evaluated
FALSEnever evaluated
0
1650 const qreal s = ct.ahsl.saturation / qreal(USHRT_MAX);-
1651 const qreal l = ct.ahsl.lightness / qreal(USHRT_MAX);-
1652-
1653 qreal temp2;-
1654 if (l < qreal(0.5))
l < qreal(0.5)Description
TRUEnever evaluated
FALSEnever evaluated
0
1655 temp2 = l * (qreal(1.0) + s);
never executed: temp2 = l * (qreal(1.0) + s);
0
1656 else-
1657 temp2 = l + s - (l * s);
never executed: temp2 = l + s - (l * s);
0
1658-
1659 const qreal temp1 = (qreal(2.0) * l) - temp2;-
1660 qreal temp3[3] = { h + (qreal(1.0) / qreal(3.0)),-
1661 h,-
1662 h - (qreal(1.0) / qreal(3.0)) };-
1663-
1664 for (int i = 0; i != 3; ++i) {
i != 3Description
TRUEnever evaluated
FALSEnever evaluated
0
1665 if (temp3[i] < qreal(0.0))
temp3[i] < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1666 temp3[i] += qreal(1.0);
never executed: temp3[i] += qreal(1.0);
0
1667 else if (temp3[i] > qreal(1.0))
temp3[i] > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1668 temp3[i] -= qreal(1.0);
never executed: temp3[i] -= qreal(1.0);
0
1669-
1670 const qreal sixtemp3 = temp3[i] * qreal(6.0);-
1671 if (sixtemp3 < qreal(1.0))
sixtemp3 < qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1672 color.ct.array[i+1] = qRound((temp1 + (temp2 - temp1) * sixtemp3) * USHRT_MAX);
never executed: color.ct.array[i+1] = qRound((temp1 + (temp2 - temp1) * sixtemp3) * (32767 * 2 + 1));
0
1673 else if ((temp3[i] * qreal(2.0)) < qreal(1.0))
(temp3[i] * qr...) < qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1674 color.ct.array[i+1] = qRound(temp2 * USHRT_MAX);
never executed: color.ct.array[i+1] = qRound(temp2 * (32767 * 2 + 1));
0
1675 else if ((temp3[i] * qreal(3.0)) < qreal(2.0))
(temp3[i] * qr...) < qreal(2.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1676 color.ct.array[i+1] = qRound((temp1 + (temp2 -temp1) * (qreal(2.0) /qreal(3.0) - temp3[i]) * qreal(6.0)) * USHRT_MAX);
never executed: color.ct.array[i+1] = qRound((temp1 + (temp2 -temp1) * (qreal(2.0) /qreal(3.0) - temp3[i]) * qreal(6.0)) * (32767 * 2 + 1));
0
1677 else-
1678 color.ct.array[i+1] = qRound(temp1 * USHRT_MAX);
never executed: color.ct.array[i+1] = qRound(temp1 * (32767 * 2 + 1));
0
1679 }-
1680 color.ct.argb.red = color.ct.argb.red == 1 ? 0 : color.ct.argb.red;
color.ct.argb.red == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1681 color.ct.argb.green = color.ct.argb.green == 1 ? 0 : color.ct.argb.green;
color.ct.argb.green == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1682 color.ct.argb.blue = color.ct.argb.blue == 1 ? 0 : color.ct.argb.blue;
color.ct.argb.blue == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1683 }
never executed: end of block
0
1684 break;
never executed: break;
0
1685 }-
1686 case Cmyk:
never executed: case Cmyk:
0
1687 {-
1688 const qreal c = ct.acmyk.cyan / qreal(USHRT_MAX);-
1689 const qreal m = ct.acmyk.magenta / qreal(USHRT_MAX);-
1690 const qreal y = ct.acmyk.yellow / qreal(USHRT_MAX);-
1691 const qreal k = ct.acmyk.black / qreal(USHRT_MAX);-
1692-
1693 color.ct.argb.red = qRound((qreal(1.0) - (c * (qreal(1.0) - k) + k)) * USHRT_MAX);-
1694 color.ct.argb.green = qRound((qreal(1.0) - (m * (qreal(1.0) - k) + k)) * USHRT_MAX);-
1695 color.ct.argb.blue = qRound((qreal(1.0) - (y * (qreal(1.0) - k) + k)) * USHRT_MAX);-
1696 break;
never executed: break;
0
1697 }-
1698 default:
never executed: default:
0
1699 break;
never executed: break;
0
1700 }-
1701-
1702 return color;
never executed: return color;
0
1703}-
1704-
1705-
1706#define Q_MAX_3(a, b, c) ( ( a > b && a > c) ? a : (b > c ? b : c) )-
1707#define Q_MIN_3(a, b, c) ( ( a < b && a < c) ? a : (b < c ? b : c) )-
1708-
1709-
1710/*!-
1711 Creates and returns an HSV QColor based on this color.-
1712-
1713 \sa fromHsv(), convertTo(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model}-
1714*/-
1715QColor QColor::toHsv() const-
1716{-
1717 if (!isValid() || cspec == Hsv)
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
cspec == HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
1718 return *this;
never executed: return *this;
0
1719-
1720 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1721 return toRgb().toHsv();
never executed: return toRgb().toHsv();
0
1722-
1723 QColor color;-
1724 color.cspec = Hsv;-
1725 color.ct.ahsv.alpha = ct.argb.alpha;-
1726 color.ct.ahsv.pad = 0;-
1727-
1728 const qreal r = ct.argb.red / qreal(USHRT_MAX);-
1729 const qreal g = ct.argb.green / qreal(USHRT_MAX);-
1730 const qreal b = ct.argb.blue / qreal(USHRT_MAX);-
1731 const qreal max = Q_MAX_3(r, g, b);
g > bDescription
TRUEnever evaluated
FALSEnever evaluated
r > gDescription
TRUEnever evaluated
FALSEnever evaluated
r > bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1732 const qreal min = Q_MIN_3(r, g, b);
g < bDescription
TRUEnever evaluated
FALSEnever evaluated
r < gDescription
TRUEnever evaluated
FALSEnever evaluated
r < bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1733 const qreal delta = max - min;-
1734 color.ct.ahsv.value = qRound(max * USHRT_MAX);-
1735 if (qFuzzyIsNull(delta)) {
qFuzzyIsNull(delta)Description
TRUEnever evaluated
FALSEnever evaluated
0
1736 // achromatic case, hue is undefined-
1737 color.ct.ahsv.hue = USHRT_MAX;-
1738 color.ct.ahsv.saturation = 0;-
1739 } else {
never executed: end of block
0
1740 // chromatic case-
1741 qreal hue = 0;-
1742 color.ct.ahsv.saturation = qRound((delta / max) * USHRT_MAX);-
1743 if (qFuzzyCompare(r, max)) {
qFuzzyCompare(r, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1744 hue = ((g - b) /delta);-
1745 } else if (qFuzzyCompare(g, max)) {
never executed: end of block
qFuzzyCompare(g, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1746 hue = (qreal(2.0) + (b - r) / delta);-
1747 } else if (qFuzzyCompare(b, max)) {
never executed: end of block
qFuzzyCompare(b, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1748 hue = (qreal(4.0) + (r - g) / delta);-
1749 } else {
never executed: end of block
0
1750 Q_ASSERT_X(false, "QColor::toHsv", "internal error");-
1751 }
never executed: end of block
0
1752 hue *= qreal(60.0);-
1753 if (hue < qreal(0.0))
hue < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1754 hue += qreal(360.0);
never executed: hue += qreal(360.0);
0
1755 color.ct.ahsv.hue = qRound(hue * 100);-
1756 }
never executed: end of block
0
1757-
1758 return color;
never executed: return color;
0
1759}-
1760-
1761/*!-
1762 Creates and returns an HSL QColor based on this color.-
1763-
1764 \sa fromHsl(), convertTo(), isValid()-
1765*/-
1766QColor QColor::toHsl() const-
1767{-
1768 if (!isValid() || cspec == Hsl)
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
cspec == HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
1769 return *this;
never executed: return *this;
0
1770-
1771 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1772 return toRgb().toHsl();
never executed: return toRgb().toHsl();
0
1773-
1774 QColor color;-
1775 color.cspec = Hsl;-
1776 color.ct.ahsl.alpha = ct.argb.alpha;-
1777 color.ct.ahsl.pad = 0;-
1778-
1779 const qreal r = ct.argb.red / qreal(USHRT_MAX);-
1780 const qreal g = ct.argb.green / qreal(USHRT_MAX);-
1781 const qreal b = ct.argb.blue / qreal(USHRT_MAX);-
1782 const qreal max = Q_MAX_3(r, g, b);
g > bDescription
TRUEnever evaluated
FALSEnever evaluated
r > gDescription
TRUEnever evaluated
FALSEnever evaluated
r > bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1783 const qreal min = Q_MIN_3(r, g, b);
g < bDescription
TRUEnever evaluated
FALSEnever evaluated
r < gDescription
TRUEnever evaluated
FALSEnever evaluated
r < bDescription
TRUEnever evaluated
FALSEnever evaluated
0
1784 const qreal delta = max - min;-
1785 const qreal delta2 = max + min;-
1786 const qreal lightness = qreal(0.5) * delta2;-
1787 color.ct.ahsl.lightness = qRound(lightness * USHRT_MAX);-
1788 if (qFuzzyIsNull(delta)) {
qFuzzyIsNull(delta)Description
TRUEnever evaluated
FALSEnever evaluated
0
1789 // achromatic case, hue is undefined-
1790 color.ct.ahsl.hue = USHRT_MAX;-
1791 color.ct.ahsl.saturation = 0;-
1792 } else {
never executed: end of block
0
1793 // chromatic case-
1794 qreal hue = 0;-
1795 if (lightness < qreal(0.5))
lightness < qreal(0.5)Description
TRUEnever evaluated
FALSEnever evaluated
0
1796 color.ct.ahsl.saturation = qRound((delta / delta2) * USHRT_MAX);
never executed: color.ct.ahsl.saturation = qRound((delta / delta2) * (32767 * 2 + 1));
0
1797 else-
1798 color.ct.ahsl.saturation = qRound((delta / (qreal(2.0) - delta2)) * USHRT_MAX);
never executed: color.ct.ahsl.saturation = qRound((delta / (qreal(2.0) - delta2)) * (32767 * 2 + 1));
0
1799 if (qFuzzyCompare(r, max)) {
qFuzzyCompare(r, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1800 hue = ((g - b) /delta);-
1801 } else if (qFuzzyCompare(g, max)) {
never executed: end of block
qFuzzyCompare(g, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1802 hue = (qreal(2.0) + (b - r) / delta);-
1803 } else if (qFuzzyCompare(b, max)) {
never executed: end of block
qFuzzyCompare(b, max)Description
TRUEnever evaluated
FALSEnever evaluated
0
1804 hue = (qreal(4.0) + (r - g) / delta);-
1805 } else {
never executed: end of block
0
1806 Q_ASSERT_X(false, "QColor::toHsv", "internal error");-
1807 }
never executed: end of block
0
1808 hue *= qreal(60.0);-
1809 if (hue < qreal(0.0))
hue < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 hue += qreal(360.0);
never executed: hue += qreal(360.0);
0
1811 color.ct.ahsl.hue = qRound(hue * 100);-
1812 }
never executed: end of block
0
1813-
1814 return color;
never executed: return color;
0
1815}-
1816-
1817/*!-
1818 Creates and returns a CMYK QColor based on this color.-
1819-
1820 \sa fromCmyk(), convertTo(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
1821*/-
1822QColor QColor::toCmyk() const-
1823{-
1824 if (!isValid() || cspec == Cmyk)
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
cspec == CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
1825 return *this;
never executed: return *this;
0
1826 if (cspec != Rgb)
cspec != RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
1827 return toRgb().toCmyk();
never executed: return toRgb().toCmyk();
0
1828-
1829 QColor color;-
1830 color.cspec = Cmyk;-
1831 color.ct.acmyk.alpha = ct.argb.alpha;-
1832-
1833 // rgb -> cmy-
1834 const qreal r = ct.argb.red / qreal(USHRT_MAX);-
1835 const qreal g = ct.argb.green / qreal(USHRT_MAX);-
1836 const qreal b = ct.argb.blue / qreal(USHRT_MAX);-
1837 qreal c = qreal(1.0) - r;-
1838 qreal m = qreal(1.0) - g;-
1839 qreal y = qreal(1.0) - b;-
1840-
1841 // cmy -> cmyk-
1842 const qreal k = qMin(c, qMin(m, y));-
1843-
1844 if (!qFuzzyIsNull(k - 1)) {
!qFuzzyIsNull(k - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1845 c = (c - k) / (qreal(1.0) - k);-
1846 m = (m - k) / (qreal(1.0) - k);-
1847 y = (y - k) / (qreal(1.0) - k);-
1848 }
never executed: end of block
0
1849-
1850 color.ct.acmyk.cyan = qRound(c * USHRT_MAX);-
1851 color.ct.acmyk.magenta = qRound(m * USHRT_MAX);-
1852 color.ct.acmyk.yellow = qRound(y * USHRT_MAX);-
1853 color.ct.acmyk.black = qRound(k * USHRT_MAX);-
1854-
1855 return color;
never executed: return color;
0
1856}-
1857-
1858QColor QColor::convertTo(QColor::Spec colorSpec) const-
1859{-
1860 if (colorSpec == cspec)
colorSpec == cspecDescription
TRUEnever evaluated
FALSEnever evaluated
0
1861 return *this;
never executed: return *this;
0
1862 switch (colorSpec) {-
1863 case Rgb:
never executed: case Rgb:
0
1864 return toRgb();
never executed: return toRgb();
0
1865 case Hsv:
never executed: case Hsv:
0
1866 return toHsv();
never executed: return toHsv();
0
1867 case Cmyk:
never executed: case Cmyk:
0
1868 return toCmyk();
never executed: return toCmyk();
0
1869 case Hsl:
never executed: case Hsl:
0
1870 return toHsl();
never executed: return toHsl();
0
1871 case Invalid:
never executed: case Invalid:
0
1872 break;
never executed: break;
0
1873 }-
1874 return QColor(); // must be invalid
never executed: return QColor();
0
1875}-
1876-
1877-
1878/*!-
1879 Static convenience function that returns a QColor constructed from the-
1880 given QRgb value \a rgb.-
1881-
1882 The alpha component of \a rgb is ignored (i.e. it is automatically set to-
1883 255), use the fromRgba() function to include the alpha-channel specified by-
1884 the given QRgb value.-
1885-
1886 \sa fromRgba(), fromRgbF(), toRgb(), isValid()-
1887*/-
1888-
1889QColor QColor::fromRgb(QRgb rgb)-
1890{-
1891 return fromRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
never executed: return fromRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
0
1892}-
1893-
1894-
1895/*!-
1896 Static convenience function that returns a QColor constructed from the-
1897 given QRgb value \a rgba.-
1898-
1899 Unlike the fromRgb() function, the alpha-channel specified by the given-
1900 QRgb value is included.-
1901-
1902 \sa fromRgb(), fromRgba64(), isValid()-
1903*/-
1904-
1905QColor QColor::fromRgba(QRgb rgba)-
1906{-
1907 return fromRgb(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));
never executed: return fromRgb(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));
0
1908}-
1909-
1910/*!-
1911 Static convenience function that returns a QColor constructed from the RGB-
1912 color values, \a r (red), \a g (green), \a b (blue), and \a a-
1913 (alpha-channel, i.e. transparency).-
1914-
1915 All the values must be in the range 0-255.-
1916-
1917 \sa toRgb(), fromRgba64(), fromRgbF(), isValid()-
1918*/-
1919QColor QColor::fromRgb(int r, int g, int b, int a)-
1920{-
1921 if (r < 0 || r > 255
r < 0Description
TRUEnever evaluated
FALSEnever evaluated
r > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1922 || g < 0 || g > 255
g < 0Description
TRUEnever evaluated
FALSEnever evaluated
g > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1923 || b < 0 || b > 255
b < 0Description
TRUEnever evaluated
FALSEnever evaluated
b > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1924 || a < 0 || a > 255) {
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1925 qWarning("QColor::fromRgb: RGB parameters out of range");-
1926 return QColor();
never executed: return QColor();
0
1927 }-
1928-
1929 QColor color;-
1930 color.cspec = Rgb;-
1931 color.ct.argb.alpha = a * 0x101;-
1932 color.ct.argb.red = r * 0x101;-
1933 color.ct.argb.green = g * 0x101;-
1934 color.ct.argb.blue = b * 0x101;-
1935 color.ct.argb.pad = 0;-
1936 return color;
never executed: return color;
0
1937}-
1938-
1939/*!-
1940 Static convenience function that returns a QColor constructed from the RGB-
1941 color values, \a r (red), \a g (green), \a b (blue), and \a a-
1942 (alpha-channel, i.e. transparency).-
1943-
1944 All the values must be in the range 0.0-1.0.-
1945-
1946 \sa fromRgb(), fromRgba64(), toRgb(), isValid()-
1947*/-
1948QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)-
1949{-
1950 if (r < qreal(0.0) || r > qreal(1.0)
r < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
r > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1951 || g < qreal(0.0) || g > qreal(1.0)
g < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
g > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1952 || b < qreal(0.0) || b > qreal(1.0)
b < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
b > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1953 || a < qreal(0.0) || a > qreal(1.0)) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1954 qWarning("QColor::fromRgbF: RGB parameters out of range");-
1955 return QColor();
never executed: return QColor();
0
1956 }-
1957-
1958 QColor color;-
1959 color.cspec = Rgb;-
1960 color.ct.argb.alpha = qRound(a * USHRT_MAX);-
1961 color.ct.argb.red = qRound(r * USHRT_MAX);-
1962 color.ct.argb.green = qRound(g * USHRT_MAX);-
1963 color.ct.argb.blue = qRound(b * USHRT_MAX);-
1964 color.ct.argb.pad = 0;-
1965 return color;
never executed: return color;
0
1966}-
1967-
1968-
1969/*!-
1970 \since 5.6-
1971-
1972 Static convenience function that returns a QColor constructed from the RGBA64-
1973 color values, \a r (red), \a g (green), \a b (blue), and \a a-
1974 (alpha-channel, i.e. transparency).-
1975-
1976 \sa fromRgb(), fromRgbF(), toRgb(), isValid()-
1977*/-
1978QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a)-
1979{-
1980 QColor color;-
1981 color.setRgba64(qRgba64(r, g, b, a));-
1982 return color;
never executed: return color;
0
1983}-
1984-
1985/*!-
1986 \since 5.6-
1987-
1988 Static convenience function that returns a QColor constructed from the-
1989 given QRgba64 value \a rgba64.-
1990-
1991 \sa fromRgb(), fromRgbF(), toRgb(), isValid()-
1992*/-
1993QColor QColor::fromRgba64(QRgba64 rgba64)-
1994{-
1995 QColor color;-
1996 color.setRgba64(rgba64);-
1997 return color;
never executed: return color;
0
1998}-
1999-
2000/*!-
2001 Static convenience function that returns a QColor constructed from the HSV-
2002 color values, \a h (hue), \a s (saturation), \a v (value), and \a a-
2003 (alpha-channel, i.e. transparency).-
2004-
2005 The value of \a s, \a v, and \a a must all be in the range 0-255; the value-
2006 of \a h must be in the range 0-359.-
2007-
2008 \sa toHsv(), fromHsvF(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model}-
2009*/-
2010QColor QColor::fromHsv(int h, int s, int v, int a)-
2011{-
2012 if (((h < 0 || h >= 360) && h != -1)
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
h >= 360Description
TRUEnever evaluated
FALSEnever evaluated
h != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2013 || s < 0 || s > 255
s < 0Description
TRUEnever evaluated
FALSEnever evaluated
s > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2014 || v < 0 || v > 255
v < 0Description
TRUEnever evaluated
FALSEnever evaluated
v > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2015 || a < 0 || a > 255) {
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2016 qWarning("QColor::fromHsv: HSV parameters out of range");-
2017 return QColor();
never executed: return QColor();
0
2018 }-
2019-
2020 QColor color;-
2021 color.cspec = Hsv;-
2022 color.ct.ahsv.alpha = a * 0x101;-
2023 color.ct.ahsv.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
h == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2024 color.ct.ahsv.saturation = s * 0x101;-
2025 color.ct.ahsv.value = v * 0x101;-
2026 color.ct.ahsv.pad = 0;-
2027 return color;
never executed: return color;
0
2028}-
2029-
2030/*!-
2031 \overload-
2032-
2033 Static convenience function that returns a QColor constructed from the HSV-
2034 color values, \a h (hue), \a s (saturation), \a v (value), and \a a-
2035 (alpha-channel, i.e. transparency).-
2036-
2037 All the values must be in the range 0.0-1.0.-
2038-
2039 \sa toHsv(), fromHsv(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model}-
2040*/-
2041QColor QColor::fromHsvF(qreal h, qreal s, qreal v, qreal a)-
2042{-
2043 if (((h < qreal(0.0) || h > qreal(1.0)) && h != qreal(-1.0))
h < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
h > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
h != qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2044 || (s < qreal(0.0) || s > qreal(1.0))
s < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
s > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2045 || (v < qreal(0.0) || v > qreal(1.0))
v < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
v > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2046 || (a < qreal(0.0) || a > qreal(1.0))) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2047 qWarning("QColor::fromHsvF: HSV parameters out of range");-
2048 return QColor();
never executed: return QColor();
0
2049 }-
2050-
2051 QColor color;-
2052 color.cspec = Hsv;-
2053 color.ct.ahsv.alpha = qRound(a * USHRT_MAX);-
2054 color.ct.ahsv.hue = h == qreal(-1.0) ? USHRT_MAX : qRound(h * 36000);
h == qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2055 color.ct.ahsv.saturation = qRound(s * USHRT_MAX);-
2056 color.ct.ahsv.value = qRound(v * USHRT_MAX);-
2057 color.ct.ahsv.pad = 0;-
2058 return color;
never executed: return color;
0
2059}-
2060-
2061/*!-
2062 \since 4.6-
2063-
2064 Static convenience function that returns a QColor constructed from the HSV-
2065 color values, \a h (hue), \a s (saturation), \a l (lightness), and \a a-
2066 (alpha-channel, i.e. transparency).-
2067-
2068 The value of \a s, \a l, and \a a must all be in the range 0-255; the value-
2069 of \a h must be in the range 0-359.-
2070-
2071 \sa toHsl(), fromHslF(), isValid()-
2072*/-
2073QColor QColor::fromHsl(int h, int s, int l, int a)-
2074{-
2075 if (((h < 0 || h >= 360) && h != -1)
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
h >= 360Description
TRUEnever evaluated
FALSEnever evaluated
h != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2076 || s < 0 || s > 255
s < 0Description
TRUEnever evaluated
FALSEnever evaluated
s > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2077 || l < 0 || l > 255
l < 0Description
TRUEnever evaluated
FALSEnever evaluated
l > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2078 || a < 0 || a > 255) {
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2079 qWarning("QColor::fromHsl: HSL parameters out of range");-
2080 return QColor();
never executed: return QColor();
0
2081 }-
2082-
2083 QColor color;-
2084 color.cspec = Hsl;-
2085 color.ct.ahsl.alpha = a * 0x101;-
2086 color.ct.ahsl.hue = h == -1 ? USHRT_MAX : (h % 360) * 100;
h == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2087 color.ct.ahsl.saturation = s * 0x101;-
2088 color.ct.ahsl.lightness = l * 0x101;-
2089 color.ct.ahsl.pad = 0;-
2090 return color;
never executed: return color;
0
2091}-
2092-
2093/*!-
2094 \overload-
2095 \since 4.6-
2096-
2097 Static convenience function that returns a QColor constructed from the HSV-
2098 color values, \a h (hue), \a s (saturation), \a l (lightness), and \a a-
2099 (alpha-channel, i.e. transparency).-
2100-
2101 All the values must be in the range 0.0-1.0.-
2102-
2103 \sa toHsl(), fromHsl(), isValid()-
2104*/-
2105QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a)-
2106{-
2107 if (((h < qreal(0.0) || h > qreal(1.0)) && h != qreal(-1.0))
h < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
h > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
h != qreal(-1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2108 || (s < qreal(0.0) || s > qreal(1.0))
s < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
s > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2109 || (l < qreal(0.0) || l > qreal(1.0))
l < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
l > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2110 || (a < qreal(0.0) || a > qreal(1.0))) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2111 qWarning("QColor::fromHslF: HSL parameters out of range");-
2112 return QColor();
never executed: return QColor();
0
2113 }-
2114-
2115 QColor color;-
2116 color.cspec = Hsl;-
2117 color.ct.ahsl.alpha = qRound(a * USHRT_MAX);-
2118 color.ct.ahsl.hue = (h == qreal(-1.0)) ? USHRT_MAX : qRound(h * 36000);
(h == qreal(-1.0))Description
TRUEnever evaluated
FALSEnever evaluated
0
2119 if (color.ct.ahsl.hue == 36000)
color.ct.ahsl.hue == 36000Description
TRUEnever evaluated
FALSEnever evaluated
0
2120 color.ct.ahsl.hue = 0;
never executed: color.ct.ahsl.hue = 0;
0
2121 color.ct.ahsl.saturation = qRound(s * USHRT_MAX);-
2122 color.ct.ahsl.lightness = qRound(l * USHRT_MAX);-
2123 color.ct.ahsl.pad = 0;-
2124 return color;
never executed: return color;
0
2125}-
2126-
2127-
2128/*!-
2129 Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the-
2130 cyan, magenta, yellow, black, and alpha-channel (transparency) components-
2131 of the color's CMYK value.-
2132-
2133 These components can be retrieved individually using the cyan(), magenta(),-
2134 yellow(), black() and alpha() functions.-
2135-
2136 \sa setCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2137*/-
2138void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a)-
2139{-
2140 if (!c || !m || !y || !k)
!cDescription
TRUEnever evaluated
FALSEnever evaluated
!mDescription
TRUEnever evaluated
FALSEnever evaluated
!yDescription
TRUEnever evaluated
FALSEnever evaluated
!kDescription
TRUEnever evaluated
FALSEnever evaluated
0
2141 return;
never executed: return;
0
2142-
2143 if (cspec != Invalid && cspec != Cmyk) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
2144 toCmyk().getCmyk(c, m, y, k, a);-
2145 return;
never executed: return;
0
2146 }-
2147-
2148 *c = ct.acmyk.cyan >> 8;-
2149 *m = ct.acmyk.magenta >> 8;-
2150 *y = ct.acmyk.yellow >> 8;-
2151 *k = ct.acmyk.black >> 8;-
2152-
2153 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
2154 *a = ct.acmyk.alpha >> 8;
never executed: *a = ct.acmyk.alpha >> 8;
0
2155}
never executed: end of block
0
2156-
2157/*!-
2158 Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the-
2159 cyan, magenta, yellow, black, and alpha-channel (transparency) components-
2160 of the color's CMYK value.-
2161-
2162 These components can be retrieved individually using the cyanF(),-
2163 magentaF(), yellowF(), blackF() and alphaF() functions.-
2164-
2165 \sa setCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2166*/-
2167void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a)-
2168{-
2169 if (!c || !m || !y || !k)
!cDescription
TRUEnever evaluated
FALSEnever evaluated
!mDescription
TRUEnever evaluated
FALSEnever evaluated
!yDescription
TRUEnever evaluated
FALSEnever evaluated
!kDescription
TRUEnever evaluated
FALSEnever evaluated
0
2170 return;
never executed: return;
0
2171-
2172 if (cspec != Invalid && cspec != Cmyk) {
cspec != InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
cspec != CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
2173 toCmyk().getCmykF(c, m, y, k, a);-
2174 return;
never executed: return;
0
2175 }-
2176-
2177 *c = ct.acmyk.cyan / qreal(USHRT_MAX);-
2178 *m = ct.acmyk.magenta / qreal(USHRT_MAX);-
2179 *y = ct.acmyk.yellow / qreal(USHRT_MAX);-
2180 *k = ct.acmyk.black / qreal(USHRT_MAX);-
2181-
2182 if (a)
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
2183 *a = ct.acmyk.alpha / qreal(USHRT_MAX);
never executed: *a = ct.acmyk.alpha / qreal((32767 * 2 + 1));
0
2184}
never executed: end of block
0
2185-
2186/*!-
2187 Sets the color to CMYK values, \a c (cyan), \a m (magenta), \a y (yellow),-
2188 \a k (black), and \a a (alpha-channel, i.e. transparency).-
2189-
2190 All the values must be in the range 0-255.-
2191-
2192 \sa getCmyk(), setCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2193*/-
2194void QColor::setCmyk(int c, int m, int y, int k, int a)-
2195{-
2196 if (c < 0 || c > 255
c < 0Description
TRUEnever evaluated
FALSEnever evaluated
c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2197 || m < 0 || m > 255
m < 0Description
TRUEnever evaluated
FALSEnever evaluated
m > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2198 || y < 0 || y > 255
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2199 || k < 0 || k > 255
k < 0Description
TRUEnever evaluated
FALSEnever evaluated
k > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2200 || a < 0 || a > 255) {
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2201 qWarning("QColor::setCmyk: CMYK parameters out of range");-
2202 return;
never executed: return;
0
2203 }-
2204-
2205 cspec = Cmyk;-
2206 ct.acmyk.alpha = a * 0x101;-
2207 ct.acmyk.cyan = c * 0x101;-
2208 ct.acmyk.magenta = m * 0x101;-
2209 ct.acmyk.yellow = y * 0x101;-
2210 ct.acmyk.black = k * 0x101;-
2211}
never executed: end of block
0
2212-
2213/*!-
2214 \overload-
2215-
2216 Sets the color to CMYK values, \a c (cyan), \a m (magenta), \a y (yellow),-
2217 \a k (black), and \a a (alpha-channel, i.e. transparency).-
2218-
2219 All the values must be in the range 0.0-1.0.-
2220-
2221 \sa getCmykF(), setCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2222*/-
2223void QColor::setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)-
2224{-
2225 if (c < qreal(0.0) || c > qreal(1.0)
c < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
c > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2226 || m < qreal(0.0) || m > qreal(1.0)
m < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
m > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2227 || y < qreal(0.0) || y > qreal(1.0)
y < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
y > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2228 || k < qreal(0.0) || k > qreal(1.0)
k < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
k > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2229 || a < qreal(0.0) || a > qreal(1.0)) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2230 qWarning("QColor::setCmykF: CMYK parameters out of range");-
2231 return;
never executed: return;
0
2232 }-
2233-
2234 cspec = Cmyk;-
2235 ct.acmyk.alpha = qRound(a * USHRT_MAX);-
2236 ct.acmyk.cyan = qRound(c * USHRT_MAX);-
2237 ct.acmyk.magenta = qRound(m * USHRT_MAX);-
2238 ct.acmyk.yellow = qRound(y * USHRT_MAX);-
2239 ct.acmyk.black = qRound(k * USHRT_MAX);-
2240}
never executed: end of block
0
2241-
2242/*!-
2243 Static convenience function that returns a QColor constructed from the-
2244 given CMYK color values: \a c (cyan), \a m (magenta), \a y (yellow), \a k-
2245 (black), and \a a (alpha-channel, i.e. transparency).-
2246-
2247 All the values must be in the range 0-255.-
2248-
2249 \sa toCmyk(), fromCmykF(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2250*/-
2251QColor QColor::fromCmyk(int c, int m, int y, int k, int a)-
2252{-
2253 if (c < 0 || c > 255
c < 0Description
TRUEnever evaluated
FALSEnever evaluated
c > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2254 || m < 0 || m > 255
m < 0Description
TRUEnever evaluated
FALSEnever evaluated
m > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2255 || y < 0 || y > 255
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2256 || k < 0 || k > 255
k < 0Description
TRUEnever evaluated
FALSEnever evaluated
k > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2257 || a < 0 || a > 255) {
a < 0Description
TRUEnever evaluated
FALSEnever evaluated
a > 255Description
TRUEnever evaluated
FALSEnever evaluated
0
2258 qWarning("QColor::fromCmyk: CMYK parameters out of range");-
2259 return QColor();
never executed: return QColor();
0
2260 }-
2261-
2262 QColor color;-
2263 color.cspec = Cmyk;-
2264 color.ct.acmyk.alpha = a * 0x101;-
2265 color.ct.acmyk.cyan = c * 0x101;-
2266 color.ct.acmyk.magenta = m * 0x101;-
2267 color.ct.acmyk.yellow = y * 0x101;-
2268 color.ct.acmyk.black = k * 0x101;-
2269 return color;
never executed: return color;
0
2270}-
2271-
2272/*!-
2273 \overload-
2274-
2275 Static convenience function that returns a QColor constructed from the-
2276 given CMYK color values: \a c (cyan), \a m (magenta), \a y (yellow), \a k-
2277 (black), and \a a (alpha-channel, i.e. transparency).-
2278-
2279 All the values must be in the range 0.0-1.0.-
2280-
2281 \sa toCmyk(), fromCmyk(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model}-
2282*/-
2283QColor QColor::fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)-
2284{-
2285 if (c < qreal(0.0) || c > qreal(1.0)
c < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
c > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2286 || m < qreal(0.0) || m > qreal(1.0)
m < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
m > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2287 || y < qreal(0.0) || y > qreal(1.0)
y < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
y > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2288 || k < qreal(0.0) || k > qreal(1.0)
k < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
k > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2289 || a < qreal(0.0) || a > qreal(1.0)) {
a < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
a > qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2290 qWarning("QColor::fromCmykF: CMYK parameters out of range");-
2291 return QColor();
never executed: return QColor();
0
2292 }-
2293-
2294 QColor color;-
2295 color.cspec = Cmyk;-
2296 color.ct.acmyk.alpha = qRound(a * USHRT_MAX);-
2297 color.ct.acmyk.cyan = qRound(c * USHRT_MAX);-
2298 color.ct.acmyk.magenta = qRound(m * USHRT_MAX);-
2299 color.ct.acmyk.yellow = qRound(y * USHRT_MAX);-
2300 color.ct.acmyk.black = qRound(k * USHRT_MAX);-
2301 return color;
never executed: return color;
0
2302}-
2303-
2304/*!-
2305 \fn QColor QColor::lighter(int factor) const-
2306 \since 4.3-
2307-
2308 Returns a lighter (or darker) color, but does not change this object.-
2309-
2310 If the \a factor is greater than 100, this functions returns a lighter-
2311 color. Setting \a factor to 150 returns a color that is 50% brighter. If-
2312 the \a factor is less than 100, the return color is darker, but we-
2313 recommend using the darker() function for this purpose. If the \a factor-
2314 is 0 or negative, the return value is unspecified.-
2315-
2316 The function converts the current RGB color to HSV, multiplies the value-
2317 (V) component by \a factor and converts the color back to RGB.-
2318-
2319 \sa darker(), isValid()-
2320*/-
2321-
2322/*!-
2323 \obsolete-
2324-
2325 Use lighter(\a factor) instead.-
2326*/-
2327QColor QColor::light(int factor) const-
2328{-
2329 if (factor <= 0) // invalid lightness factor
factor <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2330 return *this;
never executed: return *this;
0
2331 else if (factor < 100) // makes color darker
factor < 100Description
TRUEnever evaluated
FALSEnever evaluated
0
2332 return darker(10000 / factor);
never executed: return darker(10000 / factor);
0
2333-
2334 QColor hsv = toHsv();-
2335 int s = hsv.ct.ahsv.saturation;-
2336 uint v = hsv.ct.ahsv.value;-
2337-
2338 v = (factor*v)/100;-
2339 if (v > USHRT_MAX) {
v > (32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2340 // overflow... adjust saturation-
2341 s -= v - USHRT_MAX;-
2342 if (s < 0)
s < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2343 s = 0;
never executed: s = 0;
0
2344 v = USHRT_MAX;-
2345 }
never executed: end of block
0
2346-
2347 hsv.ct.ahsv.saturation = s;-
2348 hsv.ct.ahsv.value = v;-
2349-
2350 // convert back to same color spec as original color-
2351 return hsv.convertTo(cspec);
never executed: return hsv.convertTo(cspec);
0
2352}-
2353-
2354/*!-
2355 \fn QColor QColor::darker(int factor) const-
2356 \since 4.3-
2357-
2358 Returns a darker (or lighter) color, but does not change this object.-
2359-
2360 If the \a factor is greater than 100, this functions returns a darker-
2361 color. Setting \a factor to 300 returns a color that has one-third the-
2362 brightness. If the \a factor is less than 100, the return color is lighter,-
2363 but we recommend using the lighter() function for this purpose. If the-
2364 \a factor is 0 or negative, the return value is unspecified.-
2365-
2366 The function converts the current RGB color to HSV, divides the value (V)-
2367 component by \a factor and converts the color back to RGB.-
2368-
2369 \sa lighter(), isValid()-
2370*/-
2371-
2372/*!-
2373 \obsolete-
2374-
2375 Use darker(\a factor) instead.-
2376*/-
2377QColor QColor::dark(int factor) const-
2378{-
2379 if (factor <= 0) // invalid darkness factor
factor <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2380 return *this;
never executed: return *this;
0
2381 else if (factor < 100) // makes color lighter
factor < 100Description
TRUEnever evaluated
FALSEnever evaluated
0
2382 return lighter(10000 / factor);
never executed: return lighter(10000 / factor);
0
2383-
2384 QColor hsv = toHsv();-
2385 hsv.ct.ahsv.value = (hsv.ct.ahsv.value * 100) / factor;-
2386-
2387 // convert back to same color spec as original color-
2388 return hsv.convertTo(cspec);
never executed: return hsv.convertTo(cspec);
0
2389}-
2390-
2391#if QT_VERSION < QT_VERSION_CHECK(6,0,0)-
2392/*!-
2393 Assigns a copy of \a color to this color, and returns a reference to it.-
2394*/-
2395QColor &QColor::operator=(const QColor &color)-
2396{-
2397 cspec = color.cspec;-
2398 ct.argb = color.ct.argb;-
2399 return *this;
never executed: return *this;
0
2400}-
2401#endif-
2402-
2403/*! \overload-
2404 Assigns a copy of \a color and returns a reference to this color.-
2405 */-
2406QColor &QColor::operator=(Qt::GlobalColor color)-
2407{-
2408 return operator=(QColor(color));
never executed: return operator=(QColor(color));
0
2409}-
2410-
2411/*!-
2412 Returns \c true if this color has the same RGB and alpha values as \a color;-
2413 otherwise returns \c false.-
2414*/-
2415bool QColor::operator==(const QColor &color) const-
2416{-
2417 if (cspec == Hsl && cspec == color.cspec) {
cspec == HslDescription
TRUEnever evaluated
FALSEnever evaluated
cspec == color.cspecDescription
TRUEnever evaluated
FALSEnever evaluated
0
2418 return (ct.argb.alpha == color.ct.argb.alpha
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
ct.argb.alpha ....ct.argb.alphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2419 && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000)))
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
(((ct.ahsl.hue...hue % 36000)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2420 || (ct.ahsl.hue == color.ct.ahsl.hue))
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
(ct.ahsl.hue =...r.ct.ahsl.hue)Description
TRUEnever evaluated
FALSEnever evaluated
0
2421 && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
qAbs(ct.ahsl.s...turation) < 50Description
TRUEnever evaluated
FALSEnever evaluated
0
2422 || ct.ahsl.lightness == 0
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
ct.ahsl.lightness == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2423 || color.ct.ahsl.lightness == 0
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
color.ct.ahsl.lightness == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2424 || ct.ahsl.lightness == USHRT_MAX
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
ct.ahsl.lightn...32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2425 || color.ct.ahsl.lightness == USHRT_MAX)
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
color.ct.ahsl....32767 * 2 + 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2426 && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
never executed: return (ct.argb.alpha == color.ct.argb.alpha && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000))) || (ct.ahsl.hue == color.ct.ahsl.hue)) && (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50 || ct.ahsl.lightness == 0 || color.ct.ahsl.lightness == 0 || ct.ahsl.lightness == (32767 * 2 + 1) || color.ct.ahsl.lightness == (32767 * 2 + 1)) && (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
(qAbs(ct.ahsl....ghtness)) < 50Description
TRUEnever evaluated
FALSEnever evaluated
0
2427 } else {-
2428 return (cspec == color.cspec
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
cspec == color.cspecDescription
TRUEnever evaluated
FALSEnever evaluated
0
2429 && ct.argb.alpha == color.ct.argb.alpha
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
ct.argb.alpha ....ct.argb.alphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
2430 && (((cspec == QColor::Hsv)
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
(cspec == QColor::Hsv)Description
TRUEnever evaluated
FALSEnever evaluated
0
2431 && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000)))
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
((ct.ahsv.hue ....hue % 36000))Description
TRUEnever evaluated
FALSEnever evaluated
0
2432 || (ct.ahsv.hue == color.ct.ahsv.hue))
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
(ct.ahsv.hue =...r.ct.ahsv.hue)Description
TRUEnever evaluated
FALSEnever evaluated
0
2433 && ct.argb.green == color.ct.argb.green
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
ct.argb.green ....ct.argb.greenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2434 && ct.argb.blue == color.ct.argb.blue
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
ct.argb.blue =...r.ct.argb.blueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2435 && ct.argb.pad == color.ct.argb.pad);
never executed: return (cspec == color.cspec && ct.argb.alpha == color.ct.argb.alpha && (((cspec == QColor::Hsv) && ((ct.ahsv.hue % 36000) == (color.ct.ahsv.hue % 36000))) || (ct.ahsv.hue == color.ct.ahsv.hue)) && ct.argb.green == color.ct.argb.green && ct.argb.blue == color.ct.argb.blue && ct.argb.pad == color.ct.argb.pad);
ct.argb.pad ==...or.ct.argb.padDescription
TRUEnever evaluated
FALSEnever evaluated
0
2436 }-
2437}-
2438-
2439/*!-
2440 Returns \c true if this color has a different RGB and alpha values from-
2441 \a color; otherwise returns \c false.-
2442*/-
2443bool QColor::operator!=(const QColor &color) const-
2444{
never executed: return !operator==(color);
return !operator==(color); }
never executed: return !operator==(color);
0
2445-
2446-
2447/*!-
2448 Returns the color as a QVariant-
2449*/-
2450QColor::operator QVariant() const-
2451{-
2452 return QVariant(QVariant::Color, this);
never executed: return QVariant(QVariant::Color, this);
0
2453}-
2454-
2455/*! \internal-
2456-
2457 Marks the color as invalid and sets all components to zero (alpha is set-
2458 to fully opaque for compatibility with Qt 3).-
2459*/-
2460void QColor::invalidate()-
2461{-
2462 cspec = Invalid;-
2463 ct.argb.alpha = USHRT_MAX;-
2464 ct.argb.red = 0;-
2465 ct.argb.green = 0;-
2466 ct.argb.blue = 0;-
2467 ct.argb.pad = 0;-
2468}
never executed: end of block
0
2469-
2470/*****************************************************************************-
2471 QColor stream functions-
2472 *****************************************************************************/-
2473-
2474#ifndef QT_NO_DEBUG_STREAM-
2475QDebug operator<<(QDebug dbg, const QColor &c)-
2476{-
2477 QDebugStateSaver saver(dbg);-
2478 if (!c.isValid())
!c.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2479 dbg.nospace() << "QColor(Invalid)";
never executed: dbg.nospace() << "QColor(Invalid)";
0
2480 else if (c.spec() == QColor::Rgb)
c.spec() == QColor::RgbDescription
TRUEnever evaluated
FALSEnever evaluated
0
2481 dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ')';
never executed: dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ')';
0
2482 else if (c.spec() == QColor::Hsv)
c.spec() == QColor::HsvDescription
TRUEnever evaluated
FALSEnever evaluated
0
2483 dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ')';
never executed: dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ')';
0
2484 else if (c.spec() == QColor::Cmyk)
c.spec() == QColor::CmykDescription
TRUEnever evaluated
FALSEnever evaluated
0
2485 dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", "
never executed: dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", " << c.blackF()<< ')';
0
2486 << c.blackF()<< ')';
never executed: dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", " << c.blackF()<< ')';
0
2487 else if (c.spec() == QColor::Hsl)
c.spec() == QColor::HslDescription
TRUEnever evaluated
FALSEnever evaluated
0
2488 dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
never executed: dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
0
2489-
2490 return dbg;
never executed: return dbg;
0
2491}-
2492#endif-
2493-
2494#ifndef QT_NO_DATASTREAM-
2495/*!-
2496 \fn QDataStream &operator<<(QDataStream &stream, const QColor &color)-
2497 \relates QColor-
2498-
2499 Writes the \a color to the \a stream.-
2500-
2501 \sa {Serializing Qt Data Types}-
2502*/-
2503QDataStream &operator<<(QDataStream &stream, const QColor &color)-
2504{-
2505 if (stream.version() < 7) {
stream.version() < 7Description
TRUEnever evaluated
FALSEnever evaluated
0
2506 if (!color.isValid())
!color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2507 return stream << quint32(0x49000000);
never executed: return stream << quint32(0x49000000);
0
2508 quint32 p = (quint32)color.rgb();-
2509 if (stream.version() == 1) // Swap red and blue
stream.version() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2510 p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
never executed: p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
0
2511 return stream << p;
never executed: return stream << p;
0
2512 }-
2513-
2514 qint8 s = color.cspec;-
2515 quint16 a = color.ct.argb.alpha;-
2516 quint16 r = color.ct.argb.red;-
2517 quint16 g = color.ct.argb.green;-
2518 quint16 b = color.ct.argb.blue;-
2519 quint16 p = color.ct.argb.pad;-
2520-
2521 stream << s;-
2522 stream << a;-
2523 stream << r;-
2524 stream << g;-
2525 stream << b;-
2526 stream << p;-
2527-
2528 return stream;
never executed: return stream;
0
2529}-
2530-
2531/*!-
2532 \fn QDataStream &operator>>(QDataStream &stream, QColor &color)-
2533 \relates QColor-
2534-
2535 Reads the \a color from the \a stream.-
2536-
2537 \sa {Serializing Qt Data Types}-
2538*/-
2539QDataStream &operator>>(QDataStream &stream, QColor &color)-
2540{-
2541 if (stream.version() < 7) {
stream.version() < 7Description
TRUEnever evaluated
FALSEnever evaluated
0
2542 quint32 p;-
2543 stream >> p;-
2544 if (p == 0x49000000) {
p == 0x49000000Description
TRUEnever evaluated
FALSEnever evaluated
0
2545 color.invalidate();-
2546 return stream;
never executed: return stream;
0
2547 }-
2548 if (stream.version() == 1) // Swap red and blue
stream.version() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2549 p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
never executed: p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
0
2550 color.setRgb(p);-
2551 return stream;
never executed: return stream;
0
2552 }-
2553-
2554 qint8 s;-
2555 quint16 a, r, g, b, p;-
2556 stream >> s;-
2557 stream >> a;-
2558 stream >> r;-
2559 stream >> g;-
2560 stream >> b;-
2561 stream >> p;-
2562-
2563 color.cspec = QColor::Spec(s);-
2564 color.ct.argb.alpha = a;-
2565 color.ct.argb.red = r;-
2566 color.ct.argb.green = g;-
2567 color.ct.argb.blue = b;-
2568 color.ct.argb.pad = p;-
2569-
2570 return stream;
never executed: return stream;
0
2571}-
2572#endif // QT_NO_DATASTREAM-
2573-
2574// A table of precalculated results of 0x00ff00ff/alpha use by qUnpremultiply:-
2575const uint qt_inv_premul_factor[256] = {-
2576 0, 16711935, 8355967, 5570645, 4177983, 3342387, 2785322, 2387419,-
2577 2088991, 1856881, 1671193, 1519266, 1392661, 1285533, 1193709, 1114129,-
2578 1044495, 983055, 928440, 879575, 835596, 795806, 759633, 726605,-
2579 696330, 668477, 642766, 618960, 596854, 576273, 557064, 539094,-
2580 522247, 506422, 491527, 477483, 464220, 451673, 439787, 428511,-
2581 417798, 407608, 397903, 388649, 379816, 371376, 363302, 355573,-
2582 348165, 341059, 334238, 327685, 321383, 315319, 309480, 303853,-
2583 298427, 293191, 288136, 283253, 278532, 273966, 269547, 265268,-
2584 261123, 257106, 253211, 249431, 245763, 242201, 238741, 235379,-
2585 232110, 228930, 225836, 222825, 219893, 217038, 214255, 211543,-
2586 208899, 206320, 203804, 201348, 198951, 196611, 194324, 192091,-
2587 189908, 187774, 185688, 183647, 181651, 179698, 177786, 175915,-
2588 174082, 172287, 170529, 168807, 167119, 165464, 163842, 162251,-
2589 160691, 159161, 157659, 156186, 154740, 153320, 151926, 150557,-
2590 149213, 147893, 146595, 145321, 144068, 142837, 141626, 140436,-
2591 139266, 138115, 136983, 135869, 134773, 133695, 132634, 131590,-
2592 130561, 129549, 128553, 127572, 126605, 125653, 124715, 123792,-
2593 122881, 121984, 121100, 120229, 119370, 118524, 117689, 116866,-
2594 116055, 115254, 114465, 113686, 112918, 112160, 111412, 110675,-
2595 109946, 109228, 108519, 107818, 107127, 106445, 105771, 105106,-
2596 104449, 103800, 103160, 102527, 101902, 101284, 100674, 100071,-
2597 99475, 98887, 98305, 97730, 97162, 96600, 96045, 95496,-
2598 94954, 94417, 93887, 93362, 92844, 92331, 91823, 91322,-
2599 90825, 90334, 89849, 89368, 88893, 88422, 87957, 87497,-
2600 87041, 86590, 86143, 85702, 85264, 84832, 84403, 83979,-
2601 83559, 83143, 82732, 82324, 81921, 81521, 81125, 80733,-
2602 80345, 79961, 79580, 79203, 78829, 78459, 78093, 77729,-
2603 77370, 77013, 76660, 76310, 75963, 75619, 75278, 74941,-
2604 74606, 74275, 73946, 73620, 73297, 72977, 72660, 72346,-
2605 72034, 71725, 71418, 71114, 70813, 70514, 70218, 69924,-
2606 69633, 69344, 69057, 68773, 68491, 68211, 67934, 67659,-
2607 67386, 67116, 66847, 66581, 66317, 66055, 65795, 65537-
2608};-
2609-
2610/*****************************************************************************-
2611 QColor global functions (documentation only)-
2612 *****************************************************************************/-
2613-
2614/*!-
2615 \fn int qRed(QRgb rgb)-
2616 \relates QColor-
2617-
2618 Returns the red component of the ARGB quadruplet \a rgb.-
2619-
2620 \sa qRgb(), QColor::red()-
2621*/-
2622-
2623/*!-
2624 \fn int qGreen(QRgb rgb)-
2625 \relates QColor-
2626-
2627 Returns the green component of the ARGB quadruplet \a rgb.-
2628-
2629 \sa qRgb(), QColor::green()-
2630*/-
2631-
2632/*!-
2633 \fn int qBlue(QRgb rgb)-
2634 \relates QColor-
2635-
2636 Returns the blue component of the ARGB quadruplet \a rgb.-
2637-
2638 \sa qRgb(), QColor::blue()-
2639*/-
2640-
2641/*!-
2642 \fn int qAlpha(QRgb rgba)-
2643 \relates QColor-
2644-
2645 Returns the alpha component of the ARGB quadruplet \a rgba.-
2646-
2647 \sa qRgb(), QColor::alpha()-
2648*/-
2649-
2650/*!-
2651 \fn QRgb qRgb(int r, int g, int b)-
2652 \relates QColor-
2653-
2654 Returns the ARGB quadruplet (255, \a{r}, \a{g}, \a{b}).-
2655-
2656 \sa qRgba(), qRed(), qGreen(), qBlue()-
2657*/-
2658-
2659/*!-
2660 \fn QRgb qRgba(int r, int g, int b, int a)-
2661 \relates QColor-
2662-
2663 Returns the ARGB quadruplet (\a{a}, \a{r}, \a{g}, \a{b}).-
2664-
2665 \sa qRgb(), qRed(), qGreen(), qBlue()-
2666*/-
2667-
2668/*!-
2669 \fn int qGray(int r, int g, int b)-
2670 \relates QColor-
2671-
2672 Returns a gray value (0 to 255) from the (\a r, \a g, \a b)-
2673 triplet.-
2674-
2675 The gray value is calculated using the formula (\a r * 11 + \a g * 16 +-
2676 \a b * 5)/32.-
2677*/-
2678-
2679/*!-
2680 \fn int qGray(QRgb rgb)-
2681 \overload-
2682 \relates QColor-
2683-
2684 Returns a gray value (0 to 255) from the given ARGB quadruplet \a rgb.-
2685-
2686 The gray value is calculated using the formula (R * 11 + G * 16 + B * 5)/32;-
2687 the alpha-channel is ignored.-
2688*/-
2689-
2690/*!-
2691 \fn QRgb qPremultiply(QRgb rgb)-
2692 \since 5.3-
2693 \relates QColor-
2694-
2695 Converts an unpremultiplied ARGB quadruplet \a rgb into a premultiplied ARGB quadruplet.-
2696-
2697 \sa qUnpremultiply()-
2698*/-
2699-
2700/*!-
2701 \fn QRgb qUnpremultiply(QRgb rgb)-
2702 \since 5.3-
2703 \relates QColor-
2704-
2705 Converts a premultiplied ARGB quadruplet \a rgb into an unpremultiplied ARGB quadruplet.-
2706-
2707 \sa qPremultiply()-
2708*/-
2709-
2710/*!-
2711 \fn QColor QColor::convertTo(Spec colorSpec) const-
2712-
2713 Creates a copy of \e this color in the format specified by \a colorSpec.-
2714-
2715 \sa spec(), toCmyk(), toHsv(), toRgb(), isValid()-
2716*/-
2717-
2718/*!-
2719 \typedef QRgb-
2720 \relates QColor-
2721-
2722 An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.-
2723-
2724 The type also holds a value for the alpha-channel. The default alpha-
2725 channel is \c ff, i.e opaque. For more information, see the-
2726 \l{QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing} section.-
2727-
2728 \sa QColor::rgb(), QColor::rgba()-
2729*/-
2730-
2731QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9