Perceptual Color

helperconversion.cpp
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4// Own header
5#include "helperconversion.h"
6
7#include "genericcolor.h"
8#include <qglobal.h>
9
10namespace PerceptualColor
11{
12
13/**
14 * @internal
15 *
16 * @brief Conversion to @ref GenericColor with @ref ColorModel::CielabD50
17 * @param value a point in Lab representation
18 * @returns the same point as @ref GenericColor with
19 * @ref ColorModel::CielabD50
20 */
21GenericColor toGenericColorCielabD50(const cmsCIELab &value)
22{
23 cmsCIELCh tempLch;
24 cmsLab2LCh(&tempLch, &value);
25 return GenericColor(tempLch);
26}
27
28/** @internal
29 *
30 * @brief Conversion to <tt>cmsCIELab</tt>
31 * @param value the value to convert
32 * @returns the same value as <tt>cmsCIELab</tt> */
33cmsCIELab toCmsLab(const cmsCIELCh &value)
34{
35 cmsCIELab lab; // uses cmsFloat64Number internally
36 // convert from LCH to Lab
37 cmsLCh2Lab(&lab, &value);
38 return lab;
39}
40
41#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
42/** @internal
43 *
44 * @brief A qHash function for @ref ColorSpace.
45 *
46 * Qt5 needs a qHash function if QHash’s key is an enum class. Qt6 does not
47 * need this. Therefore, this function is only compiled into the Qt5 builds.
48 *
49 * @warning This is not part of the public API! It can change or be
50 * removed totally at any time. */
51uint qHash(const ColorModel t, uint seed) // clazy:exclude=qt6-qhash-signature
52{
53 using UnderlyingType = std::underlying_type<ColorModel>::type;
54 const auto underlyingValue = static_cast<UnderlyingType>(t);
55 // “::” selects one of Qt’s qHash functions (instead of recursively calling
56 // this very same function).
57 return ::qHash(underlyingValue, seed);
58}
59#endif
60
61} // namespace PerceptualColor
KCALENDARCORE_EXPORT size_t qHash(const KCalendarCore::Period &key, size_t seed=0)
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:00:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.