File indexing completed on 2025-01-18 10:07:58
0001
0002
0003
0004 #ifndef QCOLORSPACE_H
0005 #define QCOLORSPACE_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtGui/qcolortransform.h>
0009 #include <QtCore/qobjectdefs.h>
0010 #include <QtCore/qshareddata.h>
0011 #include <QtCore/qvariant.h>
0012
0013 QT_BEGIN_NAMESPACE
0014
0015 class QColorSpacePrivate;
0016 class QPointF;
0017
0018 QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QColorSpacePrivate, Q_GUI_EXPORT)
0019
0020 class Q_GUI_EXPORT QColorSpace
0021 {
0022 Q_GADGET
0023 public:
0024 enum NamedColorSpace {
0025 SRgb = 1,
0026 SRgbLinear,
0027 AdobeRgb,
0028 DisplayP3,
0029 ProPhotoRgb
0030 };
0031 Q_ENUM(NamedColorSpace)
0032 enum class Primaries {
0033 Custom = 0,
0034 SRgb,
0035 AdobeRgb,
0036 DciP3D65,
0037 ProPhotoRgb
0038 };
0039 Q_ENUM(Primaries)
0040 enum class TransferFunction {
0041 Custom = 0,
0042 Linear,
0043 Gamma,
0044 SRgb,
0045 ProPhotoRgb
0046 };
0047 Q_ENUM(TransferFunction)
0048
0049 QColorSpace() noexcept = default;
0050 QColorSpace(NamedColorSpace namedColorSpace);
0051 QColorSpace(Primaries primaries, TransferFunction transferFunction, float gamma = 0.0f);
0052 QColorSpace(Primaries primaries, float gamma);
0053 QColorSpace(Primaries primaries, const QList<uint16_t> &transferFunctionTable);
0054 QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
0055 const QPointF &greenPoint, const QPointF &bluePoint,
0056 TransferFunction transferFunction, float gamma = 0.0f);
0057 QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
0058 const QPointF &greenPoint, const QPointF &bluePoint,
0059 const QList<uint16_t> &transferFunctionTable);
0060 QColorSpace(const QPointF &whitePoint, const QPointF &redPoint,
0061 const QPointF &greenPoint, const QPointF &bluePoint,
0062 const QList<uint16_t> &redTransferFunctionTable,
0063 const QList<uint16_t> &greenTransferFunctionTable,
0064 const QList<uint16_t> &blueTransferFunctionTable);
0065 ~QColorSpace();
0066
0067 QColorSpace(const QColorSpace &colorSpace) noexcept;
0068 QColorSpace &operator=(const QColorSpace &colorSpace) noexcept
0069 {
0070 QColorSpace copy(colorSpace);
0071 swap(copy);
0072 return *this;
0073 }
0074
0075 QColorSpace(QColorSpace &&colorSpace) noexcept = default;
0076 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QColorSpace)
0077
0078 void swap(QColorSpace &colorSpace) noexcept
0079 { d_ptr.swap(colorSpace.d_ptr); }
0080
0081 Primaries primaries() const noexcept;
0082 TransferFunction transferFunction() const noexcept;
0083 float gamma() const noexcept;
0084
0085 QString description() const noexcept;
0086 void setDescription(const QString &description);
0087
0088 void setTransferFunction(TransferFunction transferFunction, float gamma = 0.0f);
0089 void setTransferFunction(const QList<uint16_t> &transferFunctionTable);
0090 void setTransferFunctions(const QList<uint16_t> &redTransferFunctionTable,
0091 const QList<uint16_t> &greenTransferFunctionTable,
0092 const QList<uint16_t> &blueTransferFunctionTable);
0093 QColorSpace withTransferFunction(TransferFunction transferFunction, float gamma = 0.0f) const;
0094 QColorSpace withTransferFunction(const QList<uint16_t> &transferFunctionTable) const;
0095 QColorSpace withTransferFunctions(const QList<uint16_t> &redTransferFunctionTable,
0096 const QList<uint16_t> &greenTransferFunctionTable,
0097 const QList<uint16_t> &blueTransferFunctionTable) const;
0098
0099 void setPrimaries(Primaries primariesId);
0100 void setPrimaries(const QPointF &whitePoint, const QPointF &redPoint,
0101 const QPointF &greenPoint, const QPointF &bluePoint);
0102
0103 void detach();
0104 bool isValid() const noexcept;
0105
0106 friend inline bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
0107 { return colorSpace1.equals(colorSpace2); }
0108 friend inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
0109 { return !(colorSpace1 == colorSpace2); }
0110
0111 static QColorSpace fromIccProfile(const QByteArray &iccProfile);
0112 QByteArray iccProfile() const;
0113
0114 QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const;
0115
0116 operator QVariant() const;
0117
0118 private:
0119 friend class QColorSpacePrivate;
0120 bool equals(const QColorSpace &other) const;
0121
0122 QExplicitlySharedDataPointer<QColorSpacePrivate> d_ptr;
0123
0124 #ifndef QT_NO_DEBUG_STREAM
0125 friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace);
0126 #endif
0127 };
0128
0129 Q_DECLARE_SHARED(QColorSpace)
0130
0131
0132 #if !defined(QT_NO_DATASTREAM)
0133 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QColorSpace &);
0134 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColorSpace &);
0135 #endif
0136
0137 #ifndef QT_NO_DEBUG_STREAM
0138 Q_GUI_EXPORT QDebug operator<<(QDebug, const QColorSpace &);
0139 #endif
0140
0141 QT_END_NAMESPACE
0142
0143 #endif