1/****************************************************************************
2**
3** Copyright (C) 2018 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#ifndef QCOLORSPACE_H
41#define QCOLORSPACE_H
42
43#include <QtGui/qtguiglobal.h>
44#include <QtGui/qcolortransform.h>
45#include <QtCore/qshareddata.h>
46
47QT_BEGIN_NAMESPACE
48
49class QColorSpacePrivate;
50
51class Q_GUI_EXPORT QColorSpace
52{
53 Q_GADGET
54public:
55 enum ColorSpaceId {
56 Undefined = 0,
57 Unknown = 1,
58 SRgb,
59 SRgbLinear,
60 AdobeRgb,
61 DisplayP3,
62 ProPhotoRgb,
63 Bt2020,
64 };
65 Q_ENUM(ColorSpaceId)
66 enum class Gamut {
67 Custom = 0,
68 SRgb,
69 AdobeRgb,
70 DciP3D65,
71 ProPhotoRgb,
72 Bt2020,
73 };
74 Q_ENUM(Gamut)
75 enum class TransferFunction {
76 Custom = 0,
77 Linear,
78 Gamma,
79 SRgb,
80 ProPhotoRgb,
81 Bt2020,
82 };
83 Q_ENUM(TransferFunction)
84
85 QColorSpace(ColorSpaceId colorSpaceId = Undefined);
86 QColorSpace(Gamut gamut, TransferFunction fun, float gamma = 0.0f);
87 QColorSpace(Gamut gamut, float gamma);
88 QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
89 const QPointF &greenPoint, const QPointF &bluePoint,
90 TransferFunction fun, float gamma = 0.0f);
91 ~QColorSpace();
92
93 QColorSpace(QColorSpace &&colorSpace) noexcept;
94 QColorSpace(const QColorSpace &colorSpace);
95 QColorSpace &operator=(QColorSpace &&colorSpace) noexcept;
96 QColorSpace &operator=(const QColorSpace &colorSpace);
97
98 void swap(QColorSpace &colorSpace) noexcept
99 { qSwap(d_ptr, colorSpace.d_ptr); }
100
101 ColorSpaceId colorSpaceId() const noexcept;
102 Gamut gamut() const noexcept;
103 TransferFunction transferFunction() const noexcept;
104 float gamma() const noexcept;
105
106 bool isValid() const noexcept;
107
108 friend Q_GUI_EXPORT bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2);
109 friend inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2);
110
111 static QColorSpace fromIccProfile(const QByteArray &iccProfile);
112 QByteArray iccProfile() const;
113
114 QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const;
115
116
117private:
118 Q_DECLARE_PRIVATE(QColorSpace)
119 QExplicitlySharedDataPointer<QColorSpacePrivate> d_ptr;
120};
121
122bool Q_GUI_EXPORT operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2);
123inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
124{
125 return !(colorSpace1 == colorSpace2);
126}
127
128Q_DECLARE_SHARED(QColorSpace)
129
130// QColorSpace stream functions
131#if !defined(QT_NO_DATASTREAM)
132Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QColorSpace &);
133Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColorSpace &);
134#endif
135
136#ifndef QT_NO_DEBUG_STREAM
137Q_GUI_EXPORT QDebug operator<<(QDebug, const QColorSpace &);
138#endif
139
140QT_END_NAMESPACE
141
142#endif // QCOLORSPACE_P_H
143