QtBase  v6.3.1
qcolorspace.h
Go to the documentation of this file.
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/qobjectdefs.h>
46 #include <QtCore/qshareddata.h>
47 #include <QtCore/qvariant.h>
48 
50 
51 class QColorSpacePrivate;
52 class QPointF;
53 
55 
56 class Q_GUI_EXPORT QColorSpace
57 {
58  Q_GADGET
59 public:
61  SRgb = 1,
65  ProPhotoRgb
66  };
67  Q_ENUM(NamedColorSpace)
68  enum class Primaries {
69  Custom = 0,
70  SRgb,
71  AdobeRgb,
72  DciP3D65,
73  ProPhotoRgb
74  };
75  Q_ENUM(Primaries)
76  enum class TransferFunction {
77  Custom = 0,
78  Linear,
79  Gamma,
80  SRgb,
81  ProPhotoRgb
82  };
83  Q_ENUM(TransferFunction)
84 
85  QColorSpace() noexcept = default;
86  QColorSpace(NamedColorSpace namedColorSpace);
87  QColorSpace(Primaries primaries, TransferFunction transferFunction, float gamma = 0.0f);
88  QColorSpace(Primaries primaries, float gamma);
89  QColorSpace(Primaries primaries, const QList<uint16_t> &transferFunctionTable);
90  QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
91  const QPointF &greenPoint, const QPointF &bluePoint,
92  TransferFunction transferFunction, float gamma = 0.0f);
93  QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
94  const QPointF &greenPoint, const QPointF &bluePoint,
95  const QList<uint16_t> &transferFunctionTable);
96  QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
97  const QPointF &greenPoint, const QPointF &bluePoint,
98  const QList<uint16_t> &redTransferFunctionTable,
99  const QList<uint16_t> &greenTransferFunctionTable,
100  const QList<uint16_t> &blueTransferFunctionTable);
102 
103  QColorSpace(const QColorSpace &colorSpace) noexcept;
104  QColorSpace &operator=(const QColorSpace &colorSpace) noexcept
105  {
106  QColorSpace copy(colorSpace);
107  swap(copy);
108  return *this;
109  }
110 
111  QColorSpace(QColorSpace &&colorSpace) noexcept = default;
113 
114  void swap(QColorSpace &colorSpace) noexcept
115  { d_ptr.swap(colorSpace.d_ptr); }
116 
117  Primaries primaries() const noexcept;
118  TransferFunction transferFunction() const noexcept;
119  float gamma() const noexcept;
120 
121  QString description() const noexcept;
122  void setDescription(const QString &description);
123 
124  void setTransferFunction(TransferFunction transferFunction, float gamma = 0.0f);
125  void setTransferFunction(const QList<uint16_t> &transferFunctionTable);
126  void setTransferFunctions(const QList<uint16_t> &redTransferFunctionTable,
127  const QList<uint16_t> &greenTransferFunctionTable,
128  const QList<uint16_t> &blueTransferFunctionTable);
129  QColorSpace withTransferFunction(TransferFunction transferFunction, float gamma = 0.0f) const;
130  QColorSpace withTransferFunction(const QList<uint16_t> &transferFunctionTable) const;
131  QColorSpace withTransferFunctions(const QList<uint16_t> &redTransferFunctionTable,
132  const QList<uint16_t> &greenTransferFunctionTable,
133  const QList<uint16_t> &blueTransferFunctionTable) const;
134 
135  void setPrimaries(Primaries primariesId);
136  void setPrimaries(const QPointF &whitePoint, const QPointF &redPoint,
137  const QPointF &greenPoint, const QPointF &bluePoint);
138 
139  void detach();
140  bool isValid() const noexcept;
141 
142  friend inline bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
143  { return colorSpace1.equals(colorSpace2); }
144  friend inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
145  { return !(colorSpace1 == colorSpace2); }
146 
147  static QColorSpace fromIccProfile(const QByteArray &iccProfile);
148  QByteArray iccProfile() const;
149 
150  QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const;
151 
152  operator QVariant() const;
153 
154 private:
155  friend class QColorSpacePrivate;
156  bool equals(const QColorSpace &other) const;
157 
159 
160 #ifndef QT_NO_DEBUG_STREAM
161  friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace);
162 #endif
163 };
164 
166 
167 // QColorSpace stream functions
168 #if !defined(QT_NO_DATASTREAM)
169 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QColorSpace &);
170 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColorSpace &);
171 #endif
172 
173 #ifndef QT_NO_DEBUG_STREAM
174 Q_GUI_EXPORT QDebug operator<<(QDebug, const QColorSpace &);
175 #endif
176 
178 
179 #endif // QCOLORSPACE_P_H
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
The QColorSpace class provides a color space abstraction.
Definition: qcolorspace.h:57
friend bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
Definition: qcolorspace.h:144
QColorSpace(QColorSpace &&colorSpace) noexcept=default
The QColorTransform class is a transformation between color spaces.
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
Definition: qlist.h:108
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
auto it unsigned count const
Definition: hb-iter.hh:848
J_COLOR_SPACE colorspace
Definition: jpeglib.h:931
#define inline
Definition: md4c.c:45
bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
Definition: qicc.cpp:638
default
Definition: devices.py:76
void
Definition: png.h:1080
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Class)
Definition: qglobal.h:556
GLfloat GLfloat f
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
Definition: qshareddata.h:315
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_GADGET
Definition: qtmetamacros.h:193
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
QSharedPointer< T > other(t)
[5]
this swap(other)