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);
105 : namedColorSpace(namedColorSpace)
142 : primaries(primaries)
143 , transferFunction(transferFunction)
147 identifyColorSpace();
155 , transferFunction(transferFunction)
158 , whitePoint(
QColorVector::fromXYChromaticity(primaries.whitePoint))
173 , transferFunction(transferFunction)
176 , whitePoint(
QColorVector::fromXYChromaticity(whitePoint))
185 , transferFunction(
QColorSpace::TransferFunction::Custom)
188 , whitePoint(
QColorVector::fromXYChromaticity(whitePoint))
197 : primaries(primaries)
198 , transferFunction(
QColorSpace::TransferFunction::Custom)
209 , transferFunction(
QColorSpace::TransferFunction::Custom)
212 , whitePoint(
QColorVector::fromXYChromaticity(primaries.whitePoint))
224 const QList<uint16_t> &redTransferFunctionTable,
225 const QList<uint16_t> &greenTransferFunctionTable,
226 const QList<uint16_t> &blueTransferFunctionTable)
228 , transferFunction(
QColorSpace::TransferFunction::Custom)
238 greenTransferFunctionTable,
239 blueTransferFunctionTable);
262 if (
qAbs(
gamma - 2.19921875f) < (1/1024.0f)) {
316 toXyz = colorSpacePrimaries.toXyzMatrix();
325 if (!
table.isEmpty() && !
table.checkValidity()) {
326 qWarning() <<
"Invalid transfer function table given to QColorSpace";
327 trc[0].
m_type = QColorTrc::Type::Uninitialized;
332 if (
table.asColorTransferFunction(&curve)) {
337 }
else if (curve.
isSRgb()) {
340 trc[0].
m_type = QColorTrc::Type::Function;
349 const QList<uint16_t> &greenTransferFunctionTable,
350 const QList<uint16_t> &blueTransferFunctionTable)
353 QColorTransferTable greenTable(greenTransferFunctionTable.size(), greenTransferFunctionTable);
354 QColorTransferTable blueTable(blueTransferFunctionTable.size(), blueTransferFunctionTable);
355 if (!redTable.isEmpty() && !greenTable.isEmpty() && !blueTable.isEmpty() &&
356 !redTable.checkValidity() && !greenTable.checkValidity() && !blueTable.checkValidity()) {
357 qWarning() <<
"Invalid transfer function table given to QColorSpace";
358 trc[0].
m_type = QColorTrc::Type::Uninitialized;
359 trc[1].
m_type = QColorTrc::Type::Uninitialized;
360 trc[2].
m_type = QColorTrc::Type::Uninitialized;
365 if (redTable.asColorTransferFunction(&curve)) {
366 trc[0].
m_type = QColorTrc::Type::Function;
372 if (greenTable.asColorTransferFunction(&curve)) {
373 trc[1].
m_type = QColorTrc::Type::Function;
379 if (blueTable.asColorTransferFunction(&curve)) {
380 trc[2].
m_type = QColorTrc::Type::Function;
386 lut.generated.storeRelease(0);
393 trc[0].
m_type = QColorTrc::Type::Function;
399 trc[0].
m_type = QColorTrc::Type::Function;
403 trc[0].
m_type = QColorTrc::Type::Function;
409 trc[0].
m_type = QColorTrc::Type::Function;
422 lut.generated.storeRelease(0);
431 ptr->colorSpaceIn =
this;
437 if (
out->isThreeComponentMatrix())
438 ptr->colorMatrix =
out->toXyz.inverted() *
ptr->colorMatrix;
439 if (
ptr->isIdentity())
449 ptr->colorSpaceIn =
this;
450 ptr->colorSpaceOut =
this;
600 qWarning() <<
"QColorSpace attempted constructed from invalid QColorSpace::NamedColorSpace: " << int(namedColorSpace);
609 if (atomicRef.testAndSetOrdered(
nullptr, tmp, cspriv))
682 qWarning() <<
"QColorSpace attempted constructed from invalid primaries:" <<
whitePoint << redPoint << greenPoint << bluePoint;
697 const QList<uint16_t> &transferFunctionTable)
711 const QList<uint16_t> &redTransferFunctionTable,
712 const QList<uint16_t> &greenTransferFunctionTable,
713 const QList<uint16_t> &blueTransferFunctionTable)
715 redTransferFunctionTable,
716 greenTransferFunctionTable,
717 blueTransferFunctionTable))
829 const QList<uint16_t> &greenTransferFunctionTable,
830 const QList<uint16_t> &blueTransferFunctionTable)
835 greenTransferFunctionTable,
836 blueTransferFunctionTable);
846 greenTransferFunctionTable,
847 blueTransferFunctionTable);
881 out.setTransferFunction(transferFunctionTable);
894 const QList<uint16_t> &greenTransferFunctionTable,
895 const QList<uint16_t> &blueTransferFunctionTable)
const
900 out.setTransferFunctions(redTransferFunctionTable, greenTransferFunctionTable, blueTransferFunctionTable);
948 toXyz = chad * toXyz;
950 && toXyz == d_ptr->
toXyz && chad == d_ptr->
chad)
959 d_ptr->
toXyz = toXyz;
1004 QColorVector whiteScale = rawToXyz.inverted().map(wXyz);
1160 return element.
trc[0] ==
other.trc[0]
1169 return element ==
other;
1175 return element ==
other;
1209 if (d_ptr ==
other.d_ptr)
1227 const bool valid1 =
isValid();
1228 const bool valid2 =
other->isValid();
1229 if (valid1 != valid2)
1231 if (!valid1 && !valid2) {
1308 if (*
this == colorspace)
1310 if (!colorspace.isValidTarget()) {
1311 qWarning() <<
"QColorSpace::transformationToColorSpace: colorspace not a valid target";
1360#if !defined(QT_NO_DATASTREAM)
1395#ifndef QT_NO_DEBUG_STREAM
1398 return dbg <<
":Transfer";
1402 return dbg <<
":Matrix";
1406 return dbg <<
":Offset";
1410 return dbg <<
":CLUT";
1415 std::visit([&](
auto &&elm) { dbg << elm; }, element);
1422 dbg <<
"QColorSpace(";
1423 if (colorSpace.d_ptr) {
1429 dbg <<
" with profile data";
1432 dbg <<
", gamma=" << colorSpace.
gamma();
1438 dbg <<
"A2B" << colorSpace.d_ptr->
mAB;
1440 dbg <<
", B2A" << colorSpace.d_ptr->
mBA;
1450#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(const 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 fromProPhotoRgb()
static QColorTransferFunction fromSRgb()
QColorTransferFunction m_fun
QColorTransferTable m_table
static constexpr QColorVector D50()
static constexpr QPointF D65Chromaticity()
static constexpr bool isValidChromaticity(const QPointF &chr)
constexpr bool isNull() const noexcept
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::ProPhotoRgb]
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]