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