29 if (prv && !prv->ref.deref())
40 redPoint =
QPointF(0.640, 0.330);
41 greenPoint =
QPointF(0.300, 0.600);
42 bluePoint =
QPointF(0.150, 0.060);
46 redPoint =
QPointF(0.680, 0.320);
47 greenPoint =
QPointF(0.265, 0.690);
48 bluePoint =
QPointF(0.150, 0.060);
52 redPoint =
QPointF(0.640, 0.330);
53 greenPoint =
QPointF(0.210, 0.710);
54 bluePoint =
QPointF(0.150, 0.060);
58 redPoint =
QPointF(0.7347, 0.2653);
59 greenPoint =
QPointF(0.1596, 0.8404);
60 bluePoint =
QPointF(0.0366, 0.0001);
64 redPoint =
QPointF(0.708, 0.292);
65 greenPoint =
QPointF(0.170, 0.797);
66 bluePoint =
QPointF(0.131, 0.046);
111 : namedColorSpace(namedColorSpace)
163 : primaries(primaries)
164 , transferFunction(transferFunction)
176 , transferFunction(transferFunction)
179 , whitePoint(
QColorVector::fromXYChromaticity(primaries.whitePoint))
194 , transferFunction(transferFunction)
197 , whitePoint(
QColorVector::fromXYChromaticity(whitePoint))
206 , transferFunction(
QColorSpace::TransferFunction::Custom)
209 , whitePoint(
QColorVector::fromXYChromaticity(whitePoint))
218 : primaries(primaries)
219 , transferFunction(
QColorSpace::TransferFunction::Custom)
230 , transferFunction(
QColorSpace::TransferFunction::Custom)
233 , whitePoint(
QColorVector::fromXYChromaticity(primaries.whitePoint))
245 const QList<uint16_t> &redTransferFunctionTable,
246 const QList<uint16_t> &greenTransferFunctionTable,
247 const QList<uint16_t> &blueTransferFunctionTable)
249 , transferFunction(
QColorSpace::TransferFunction::Custom)
259 greenTransferFunctionTable,
260 blueTransferFunctionTable);
283 if (
qAbs(
gamma - 2.19921875f) < (1/1024.0f)) {
357 toXyz = colorSpacePrimaries.toXyzMatrix();
366 if (!
table.isEmpty() && !
table.checkValidity()) {
367 qWarning() <<
"Invalid transfer function table given to QColorSpace";
368 trc[0].
m_type = QColorTrc::Type::Uninitialized;
373 if (
table.asColorTransferFunction(&curve)) {
378 }
else if (curve.
isSRgb()) {
381 trc[0].
m_type = QColorTrc::Type::ParameterizedFunction;
390 const QList<uint16_t> &greenTransferFunctionTable,
391 const QList<uint16_t> &blueTransferFunctionTable)
394 QColorTransferTable greenTable(greenTransferFunctionTable.size(), greenTransferFunctionTable);
395 QColorTransferTable blueTable(blueTransferFunctionTable.size(), blueTransferFunctionTable);
396 if (!redTable.isEmpty() && !greenTable.isEmpty() && !blueTable.isEmpty() &&
397 !redTable.checkValidity() && !greenTable.checkValidity() && !blueTable.checkValidity()) {
398 qWarning() <<
"Invalid transfer function table given to QColorSpace";
399 trc[0].
m_type = QColorTrc::Type::Uninitialized;
400 trc[1].
m_type = QColorTrc::Type::Uninitialized;
401 trc[2].
m_type = QColorTrc::Type::Uninitialized;
406 if (redTable.asColorTransferFunction(&curve)) {
407 trc[0].
m_type = QColorTrc::Type::ParameterizedFunction;
413 if (greenTable.asColorTransferFunction(&curve)) {
414 trc[1].
m_type = QColorTrc::Type::ParameterizedFunction;
420 if (blueTable.asColorTransferFunction(&curve)) {
421 trc[2].
m_type = QColorTrc::Type::ParameterizedFunction;
427 lut.generated.storeRelease(0);
470 lut.generated.storeRelease(0);
479 ptr->colorSpaceIn =
this;
485 if (
out->isThreeComponentMatrix())
486 ptr->colorMatrix =
out->toXyz.inverted() *
ptr->colorMatrix;
487 if (
ptr->isIdentity())
497 ptr->colorSpaceIn =
this;
498 ptr->colorSpaceOut =
this;
658 qWarning() <<
"QColorSpace attempted constructed from invalid QColorSpace::NamedColorSpace: " << int(namedColorSpace);
667 if (atomicRef.testAndSetOrdered(
nullptr, tmp, cspriv))
740 qWarning() <<
"QColorSpace attempted constructed from invalid primaries:" <<
whitePoint << redPoint << greenPoint << bluePoint;
755 const QList<uint16_t> &transferFunctionTable)
769 const QList<uint16_t> &redTransferFunctionTable,
770 const QList<uint16_t> &greenTransferFunctionTable,
771 const QList<uint16_t> &blueTransferFunctionTable)
773 redTransferFunctionTable,
774 greenTransferFunctionTable,
775 blueTransferFunctionTable))
887 const QList<uint16_t> &greenTransferFunctionTable,
888 const QList<uint16_t> &blueTransferFunctionTable)
893 greenTransferFunctionTable,
894 blueTransferFunctionTable);
904 greenTransferFunctionTable,
905 blueTransferFunctionTable);
939 out.setTransferFunction(transferFunctionTable);
952 const QList<uint16_t> &greenTransferFunctionTable,
953 const QList<uint16_t> &blueTransferFunctionTable)
const
958 out.setTransferFunctions(redTransferFunctionTable, greenTransferFunctionTable, blueTransferFunctionTable);
1006 toXyz = chad * toXyz;
1008 && toXyz == d_ptr->
toXyz && chad == d_ptr->
chad)
1017 d_ptr->
toXyz = toXyz;
1062 QColorVector whiteScale = rawToXyz.inverted().map(wXyz);
1220 return element.
trc[0] ==
other.trc[0]
1229 return element ==
other;
1235 return element ==
other;
1269 if (d_ptr ==
other.d_ptr)
1287 const bool valid1 =
isValid();
1288 const bool valid2 =
other->isValid();
1289 if (valid1 != valid2)
1291 if (!valid1 && !valid2) {
1368 if (*
this == colorspace)
1370 if (!colorspace.isValidTarget()) {
1371 qWarning() <<
"QColorSpace::transformationToColorSpace: colorspace not a valid target";
1420#if !defined(QT_NO_DATASTREAM)
1455#ifndef QT_NO_DEBUG_STREAM
1458 return dbg <<
":Transfer";
1462 return dbg <<
":Matrix";
1466 return dbg <<
":Offset";
1470 return dbg <<
":CLUT";
1475 std::visit([&](
auto &&elm) { dbg << elm; }, element);
1482 dbg <<
"QColorSpace(";
1483 if (colorSpace.d_ptr) {
1491 dbg <<
" with profile data";
1495 dbg <<
"=" << colorSpace.
gamma();
1501 dbg <<
"A2B" << colorSpace.d_ptr->
mAB;
1503 dbg <<
", B2A" << colorSpace.d_ptr->
mBA;
1513#include "moc_qcolorspace.cpp"
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QList< QColorVector > table
QColorMatrix inverted() const
static QColorMatrix identity()
static QColorMatrix fromScale(QColorVector v)
static QColorMatrix chromaticAdaptation(const QColorVector &whitePoint)
QColorVector map(const QColorVector &c) const
constexpr bool isNull() const
QColorMatrix toXyzMatrix() const
void setTransferFunctionTables(const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable)
QColorTransform transformationToColorSpace(const QColorSpacePrivate *out) const
QColorSpace::TransformModel transformModel
void clearElementListProcessingForEdit()
QColorSpace::NamedColorSpace namedColorSpace
void setTransferFunctionTable(const QList< uint16_t > &transferFunctionTable)
QColorTransform transformationToXYZ() const
bool isThreeComponentMatrix() const
static Q_CONSTINIT QBasicMutex s_lutWriteLock
void setTransferFunction()
void identifyColorSpace()
bool isValid() const noexcept
struct QColorSpacePrivate::LUT lut
QColorSpace::Primaries primaries
QColorSpace::TransferFunction transferFunction
QColorSpace::ColorModel colorModel
std::variant< TransferElement, QColorMatrix, QColorVector, QColorCLUT > Element
static constexpr QColorSpace::NamedColorSpace Unknown
bool equals(const QColorSpacePrivate *other) const
The QColorSpace class provides a color space abstraction.
Primaries primaries() const noexcept
Returns the predefined primaries of the color space or primaries::Custom if it doesn't match any of t...
friend class QColorSpacePrivate
TransformModel transformModel() const noexcept
Returns the transfrom processing model used for this color space.
Primaries
Predefined sets of primary colors.
QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const
Generates and returns a color space transformation from this color space to colorspace.
bool isValid() const noexcept
Returns true if the color space is valid.
QColorSpace withTransferFunctions(const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable) const
Returns a copy of this color space, except using the transfer functions described by redTransferFunct...
void setTransferFunction(TransferFunction transferFunction, float gamma=0.0f)
Sets the transfer function to transferFunction and gamma.
float gamma() const noexcept
Returns the gamma value of color spaces with TransferFunction::Gamma, an approximate gamma value for ...
static QColorSpace fromIccProfile(const QByteArray &iccProfile)
Creates a QColorSpace from ICC profile iccProfile.
TransferFunction transferFunction() const noexcept
Returns the predefined transfer function of the color space or TransferFunction::Custom if it doesn't...
NamedColorSpace
Predefined color spaces.
void setTransferFunctions(const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable)
Sets the transfer functions to redTransferFunctionTable, greenTransferFunctionTable and blueTransferF...
void setPrimaries(Primaries primariesId)
Sets the primaries to those of the primariesId set.
ColorModel colorModel() const noexcept
Returns the color model this color space can represent.
void setDescription(const QString &description)
Sets the name or short description of the color space to description.
TransferFunction
Predefined transfer functions or gamma curves.
void setWhitePoint(QPointF whitePoint)
Sets the white point to used for this color space to whitePoint.
QColorSpace() noexcept=default
Creates a new colorspace object that represents an undefined and invalid colorspace.
QColorSpace withTransferFunction(TransferFunction transferFunction, float gamma=0.0f) const
Returns a copy of this color space, except using the transfer function transferFunction and gamma.
bool isValidTarget() const noexcept
QPointF whitePoint() const
Returns the white point used for this color space.
QString description() const noexcept
Returns the name or short description.
QByteArray iccProfile() const
Returns an ICC profile representing the color space.
static QColorTransferFunction fromGamma(float gamma)
static QColorTransferFunction fromBt2020()
static QColorTransferFunction fromProPhotoRgb()
static QColorTransferFunction fromSRgb()
static QColorTransferGenericFunction pq()
static QColorTransferGenericFunction hlg()
QColorTransferFunction m_fun
QColorTransferTable m_table
static constexpr QColorVector D50()
static constexpr QPointF D65Chromaticity()
static constexpr bool isValidChromaticity(const QPointF &chr)
static constexpr QColorVector fromXYChromaticity(QPointF chr)
QPointF toChromaticity() const
static constexpr QPointF D50Chromaticity()
\inmodule QtCore\reentrant
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
qsizetype size() const noexcept
bool isEmpty() const noexcept
qsizetype count() const noexcept
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
QByteArray toIccProfile(const QColorSpace &space)
Combined button and popup list for selecting options.
static void cleanupPredefinedColorspaces()
static bool compareElement(const QColorSpacePrivate::TransferElement &element, const QColorSpacePrivate::TransferElement &other)
QDataStream & operator>>(QDataStream &s, QColorSpace &colorSpace)
QDataStream & operator<<(QDataStream &s, const QColorSpace &image)
static bool compareElements(const T &element, const QColorSpacePrivate::Element &other)
static Q_CONSTINIT QAtomicPointer< QColorSpacePrivate > s_predefinedColorspacePrivates[QColorSpace::Bt2100Hlg]
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
bool qFuzzyIsNull(qfloat16 f) noexcept
static ControlElement< T > * ptr(QWidget *widget)
constexpr T qAbs(const T &t)
GLuint GLenum GLenum transform
GLenum GLenum GLsizei void * table
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define QStringLiteral(str)
static const QTextHtmlElement elements[Html_NumElements]
QTextStream out(stdout)
[7]