![]() |
Qt 6.x
The Qt SDK
|
The QColorSpace class provides a color space abstraction. More...
#include <qcolorspace.h>
Public Types | |
enum | NamedColorSpace { SRgb = 1 , SRgbLinear , AdobeRgb , DisplayP3 , ProPhotoRgb } |
Predefined color spaces. More... | |
enum class | Primaries { Custom = 0 , SRgb , AdobeRgb , DciP3D65 , ProPhotoRgb } |
Predefined sets of primary colors. More... | |
enum class | TransferFunction { Custom = 0 , Linear , Gamma , SRgb , ProPhotoRgb } |
Predefined transfer functions or gamma curves. More... | |
Public Member Functions | |
QColorSpace () noexcept=default | |
Creates a new colorspace object that represents an undefined and invalid colorspace. | |
QColorSpace (NamedColorSpace namedColorSpace) | |
Creates a new colorspace object that represents a namedColorSpace. | |
QColorSpace (Primaries primaries, TransferFunction transferFunction, float gamma=0.0f) | |
Creates a custom color space with the primaries primaries, using the transfer function transferFunction and optionally gamma. | |
QColorSpace (Primaries primaries, float gamma) | |
Creates a custom color space with the primaries primaries, using a gamma transfer function of gamma. | |
QColorSpace (Primaries primaries, const QList< uint16_t > &transferFunctionTable) | |
Creates a custom color space with the primaries gamut, using a custom transfer function described by transferFunctionTable. | |
QColorSpace (const QPointF &whitePoint, const QPointF &redPoint, const QPointF &greenPoint, const QPointF &bluePoint, TransferFunction transferFunction, float gamma=0.0f) | |
Creates a custom colorspace with a primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the transfer function transferFunction and optionally gamma. | |
QColorSpace (const QPointF &whitePoint, const QPointF &redPoint, const QPointF &greenPoint, const QPointF &bluePoint, const QList< uint16_t > &transferFunctionTable) | |
Creates a custom color space with primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the custom transfer function described by transferFunctionTable. | |
QColorSpace (const QPointF &whitePoint, const QPointF &redPoint, const QPointF &greenPoint, const QPointF &bluePoint, const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable) | |
Creates a custom color space with primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the custom transfer functions described by redTransferFunctionTable, greenTransferFunctionTable, and blueTransferFunctionTable. | |
~QColorSpace () | |
QColorSpace (const QColorSpace &colorSpace) noexcept | |
QColorSpace & | operator= (const QColorSpace &colorSpace) noexcept |
QColorSpace (QColorSpace &&colorSpace) noexcept=default | |
void | swap (QColorSpace &colorSpace) noexcept |
Swaps color space other with this color space. | |
Primaries | primaries () const noexcept |
Returns the predefined primaries of the color space or primaries::Custom if it doesn't match any of them. | |
TransferFunction | transferFunction () const noexcept |
Returns the predefined transfer function of the color space or TransferFunction::Custom if it doesn't match any of them. | |
float | gamma () const noexcept |
Returns the gamma value of color spaces with TransferFunction::Gamma , an approximate gamma value for other predefined color spaces, or 0.0 if no approximate gamma is known. | |
QString | description () const noexcept |
Returns the name or short description. | |
void | setDescription (const QString &description) |
Sets the name or short description of the color space to description. | |
void | setTransferFunction (TransferFunction transferFunction, float gamma=0.0f) |
Sets the transfer function to transferFunction and gamma. | |
void | setTransferFunction (const QList< uint16_t > &transferFunctionTable) |
Sets the transfer function to transferFunctionTable. | |
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 blueTransferFunctionTable. | |
QColorSpace | withTransferFunction (TransferFunction transferFunction, float gamma=0.0f) const |
Returns a copy of this color space, except using the transfer function transferFunction and gamma. | |
QColorSpace | withTransferFunction (const QList< uint16_t > &transferFunctionTable) const |
Returns a copy of this color space, except using the transfer function described by transferFunctionTable. | |
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 redTransferFunctionTable, greenTransferFunctionTable and blueTransferFunctionTable. | |
void | setPrimaries (Primaries primariesId) |
Sets the primaries to those of the primariesId set. | |
void | setPrimaries (const QPointF &whitePoint, const QPointF &redPoint, const QPointF &greenPoint, const QPointF &bluePoint) |
Set primaries to the chromaticities of whitePoint, redPoint, greenPoint and bluePoint. | |
void | detach () |
bool | isValid () const noexcept |
Returns true if the color space is valid. | |
QByteArray | iccProfile () const |
Returns an ICC profile representing the color space. | |
QColorTransform | transformationToColorSpace (const QColorSpace &colorspace) const |
Generates and returns a color space transformation from this color space to colorspace. | |
operator QVariant () const | |
Returns the color space as a QVariant. | |
Static Public Member Functions | |
static QColorSpace | fromIccProfile (const QByteArray &iccProfile) |
Creates a QColorSpace from ICC profile iccProfile. | |
Friends | |
class | QColorSpacePrivate |
bool | operator== (const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) |
Returns true if colorspace colorSpace1 is equal to colorspace colorSpace2; otherwise returns false . | |
bool | operator!= (const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) |
Returns true if colorspace colorSpace1 is not equal to colorspace colorSpace2; otherwise returns false . | |
Q_GUI_EXPORT QDebug | operator<< (QDebug dbg, const QColorSpace &colorSpace) |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QColorSpace &colorSpace) |
Writes the given colorSpace to the given stream as an ICC profile. | |
QDataStream & | operator>> (QDataStream &stream, QColorSpace &colorSpace) |
Reads a color space from the given stream and stores it in the given colorSpace. | |
The QColorSpace class provides a color space abstraction.
\inmodule QtGui
Color values can be interpreted in different ways, and based on the interpretation can live in different spaces. We call this {color spaces}.
QColorSpace provides access to creating several predefined color spaces and can generate QColorTransforms for converting colors from one color space to another.
QColorSpace can also represent color spaces defined by ICC profiles or embedded in images, that do not otherwise fit the predefined color spaces.
A color space can generally speaking be conceived as a combination of set of primary colors and a transfer function. The primaries defines the axes of the color space, and the transfer function how values are mapped on the axes. The primaries are defined by three primary colors that represent exactly how red, green, and blue look in this particular color space, and a white color that represents where and how bright pure white is. The range of colors expressible by the primary colors is called the gamut, and a color space that can represent a wider range of colors is also known as a wide-gamut color space.
The transfer function or gamma curve determines how each component in the color space is encoded. These are used because human perception does not operate linearly, and the transfer functions try to ensure that colors will seem evenly spaced to human eyes.
Definition at line 20 of file qcolorspace.h.
Predefined color spaces.
\value SRgb The sRGB color space, which Qt operates in by default. It is a close approximation of how most classic monitors operate, and a mode most software and hardware support. \l{http://www.color.org/chardata/rgb/srgb.xalter}{ICC registration of sRGB}. \value SRgbLinear The sRGB color space with linear gamma. Useful for gamma-corrected blending. \value AdobeRgb The Adobe RGB color space is a classic wide-gamut color space, using a gamma of 2.2. \l{http://www.color.org/chardata/rgb/adobergb.xalter}{ICC registration of Adobe RGB (1998)} \value DisplayP3 A color-space using the primaries of DCI-P3, but with the whitepoint and transfer function of sRGB. Common in modern wide-gamut screens. \l{http://www.color.org/chardata/rgb/DCIP3.xalter}{ICC registration of DCI-P3} \value ProPhotoRgb The Pro Photo RGB color space, also known as ROMM RGB is a very wide gamut color space. \l{http://www.color.org/chardata/rgb/rommrgb.xalter}{ICC registration of ROMM RGB}
Enumerator | |
---|---|
SRgb | |
SRgbLinear | |
AdobeRgb | |
DisplayP3 | |
ProPhotoRgb |
Definition at line 24 of file qcolorspace.h.
|
strong |
Predefined sets of primary colors.
\value Custom The primaries are undefined or does not match any predefined sets. \value SRgb The sRGB primaries \value AdobeRgb The Adobe RGB primaries \value DciP3D65 The DCI-P3 primaries with the D65 whitepoint \value ProPhotoRgb The ProPhoto RGB primaries with the D50 whitepoint
Enumerator | |
---|---|
Custom | |
SRgb | |
AdobeRgb | |
DciP3D65 | |
ProPhotoRgb |
Definition at line 32 of file qcolorspace.h.
|
strong |
Predefined transfer functions or gamma curves.
\value Custom The custom or null transfer function \value Linear The linear transfer functions \value Gamma A transfer function that is a real gamma curve based on the value of gamma() \value SRgb The sRGB transfer function, composed of linear and gamma parts \value ProPhotoRgb The ProPhoto RGB transfer function, composed of linear and gamma parts
Enumerator | |
---|---|
Custom | |
Linear | |
Gamma | |
SRgb | |
ProPhotoRgb |
Definition at line 40 of file qcolorspace.h.
|
defaultnoexcept |
Creates a new colorspace object that represents an undefined and invalid colorspace.
QColorSpace::QColorSpace | ( | NamedColorSpace | namedColorSpace | ) |
Creates a new colorspace object that represents a namedColorSpace.
Definition at line 524 of file qcolorspace.cpp.
References isValid(), ProPhotoRgb, Q_ASSERT, QColorSpacePrivate, qWarning, and s_predefinedColorspacePrivates.
QColorSpace::QColorSpace | ( | QColorSpace::Primaries | primaries, |
QColorSpace::TransferFunction | transferFunction, | ||
float | gamma = 0.0f |
||
) |
Creates a custom color space with the primaries primaries, using the transfer function transferFunction and optionally gamma.
Definition at line 549 of file qcolorspace.cpp.
QColorSpace::QColorSpace | ( | QColorSpace::Primaries | primaries, |
float | gamma | ||
) |
Creates a custom color space with the primaries primaries, using a gamma transfer function of gamma.
Definition at line 558 of file qcolorspace.cpp.
QColorSpace::QColorSpace | ( | QColorSpace::Primaries | gamut, |
const QList< uint16_t > & | transferFunctionTable | ||
) |
Creates a custom color space with the primaries gamut, using a custom transfer function described by transferFunctionTable.
The table should contain at least 2 values, and contain an monotonically increasing list of values from 0 to 65535.
Definition at line 572 of file qcolorspace.cpp.
QColorSpace::QColorSpace | ( | const QPointF & | whitePoint, |
const QPointF & | redPoint, | ||
const QPointF & | greenPoint, | ||
const QPointF & | bluePoint, | ||
QColorSpace::TransferFunction | transferFunction, | ||
float | gamma = 0.0f |
||
) |
Creates a custom colorspace with a primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the transfer function transferFunction and optionally gamma.
Definition at line 581 of file qcolorspace.cpp.
References gamma(), primaries(), QColorSpacePrivate, qWarning, and transferFunction().
QColorSpace::QColorSpace | ( | const QPointF & | whitePoint, |
const QPointF & | redPoint, | ||
const QPointF & | greenPoint, | ||
const QPointF & | bluePoint, | ||
const QList< uint16_t > & | transferFunctionTable | ||
) |
Creates a custom color space with primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the custom transfer function described by transferFunctionTable.
Definition at line 600 of file qcolorspace.cpp.
QColorSpace::QColorSpace | ( | const QPointF & | whitePoint, |
const QPointF & | redPoint, | ||
const QPointF & | greenPoint, | ||
const QPointF & | bluePoint, | ||
const QList< uint16_t > & | redTransferFunctionTable, | ||
const QList< uint16_t > & | greenTransferFunctionTable, | ||
const QList< uint16_t > & | blueTransferFunctionTable | ||
) |
Creates a custom color space with primaries based on the chromaticities of the primary colors whitePoint, redPoint, greenPoint and bluePoint, and using the custom transfer functions described by redTransferFunctionTable, greenTransferFunctionTable, and blueTransferFunctionTable.
Definition at line 614 of file qcolorspace.cpp.
|
default |
|
defaultnoexcept |
|
defaultnoexcept |
|
noexcept |
Returns the name or short description.
If a description hasn't been given in setDescription(), the original name of the profile is returned if the profile is unmodified, a guessed name is returned if the profile has been recognized as a known color space, otherwise an empty string is returned.
Definition at line 1009 of file qcolorspace.cpp.
References QColorSpacePrivate::description, QString::isEmpty(), and QColorSpacePrivate::userDescription.
Referenced by setDescription(), QIcc::toIccProfile(), and QPNGImageWriter::writeImage().
void QColorSpace::detach | ( | ) |
Definition at line 852 of file qcolorspace.cpp.
References QExplicitlySharedDataPointer< T >::detach(), and QColorSpacePrivate.
Referenced by QIcc::fromIccProfile(), fromIccProfile(), setDescription(), setPrimaries(), setPrimaries(), setTransferFunction(), setTransferFunction(), and setTransferFunctions().
|
static |
Creates a QColorSpace from ICC profile iccProfile.
If the ICC profile is not supported an invalid QColorSpace is returned where you can still read the original ICC profile using iccProfile().
Definition at line 894 of file qcolorspace.cpp.
References detach(), QIcc::fromIccProfile(), iccProfile(), and QColorSpacePrivate::iccProfile.
Referenced by operator>>(), QJpegHandlerPrivate::read(), QTiffHandler::read(), QWebpHandler::read(), and QPngHandlerPrivate::readPngHeader().
|
noexcept |
Returns the gamma value of color spaces with TransferFunction::Gamma
, an approximate gamma value for other predefined color spaces, or 0.0 if no approximate gamma is known.
Definition at line 669 of file qcolorspace.cpp.
References QColorSpacePrivate::gamma, and Q_UNLIKELY.
Referenced by QColorSpace(), setTransferFunction(), withTransferFunction(), and QPNGImageWriter::writeImage().
QByteArray QColorSpace::iccProfile | ( | ) | const |
Returns an ICC profile representing the color space.
If the color space was generated from an ICC profile, that profile is returned, otherwise one is generated.
Definition at line 872 of file qcolorspace.cpp.
References QColorSpacePrivate::iccProfile, QByteArray::isEmpty(), isValid(), Q_UNLIKELY, and QIcc::toIccProfile().
Referenced by fromIccProfile(), and QPNGImageWriter::writeImage().
|
noexcept |
Returns true
if the color space is valid.
Definition at line 907 of file qcolorspace.cpp.
References QColorMatrix::isValid(), QColorTrc::isValid(), QColorSpacePrivate::toXyz, and QColorSpacePrivate::trc.
Referenced by QColorSpace(), convert_ARGB_to_gray16(), convert_ARGB_to_gray8(), convert_Indexed8_to_Grayscale8(), convert_RGBA64_to_gray16(), convert_RGBA64_to_gray8(), QImage::convertedToColorSpace(), QImage::convertToColorSpace(), destStoreGray16(), destStoreGray8(), iccProfile(), readImage(), QPngHandlerPrivate::readPngHeader(), QPngHandlerPrivate::readPngImage(), QIcc::toIccProfile(), transformationToColorSpace(), withTransferFunction(), withTransferFunction(), and withTransferFunctions().
QColorSpace::operator QVariant | ( | ) | const |
Returns the color space as a QVariant.
Definition at line 996 of file qcolorspace.cpp.
References QVariant::fromValue().
|
inlinenoexcept |
Definition at line 68 of file qcolorspace.h.
References copy(), and swap().
|
noexcept |
Returns the predefined primaries of the color space or primaries::Custom
if it doesn't match any of them.
Definition at line 642 of file qcolorspace.cpp.
References Custom, QColorSpacePrivate::primaries, and Q_UNLIKELY.
Referenced by QColorSpace(), and setPrimaries().
Sets the name or short description of the color space to description.
If set to empty description() will return original or guessed descriptions instead.
Definition at line 1024 of file qcolorspace.cpp.
References description(), detach(), and QColorSpacePrivate::userDescription.
void QColorSpace::setPrimaries | ( | const QPointF & | whitePoint, |
const QPointF & | redPoint, | ||
const QPointF & | greenPoint, | ||
const QPointF & | bluePoint | ||
) |
Set primaries to the chromaticities of whitePoint, redPoint, greenPoint and bluePoint.
Definition at line 828 of file qcolorspace.cpp.
References QString::clear(), Custom, QColorSpacePrivate::description, detach(), QColorSpacePrivate::identifyColorSpace(), primaries(), QColorSpacePrivate::primaries, QColorSpacePrivate, QColorSpacePrivate::toXyz, and QColorSpacePrivate::whitePoint.
void QColorSpace::setPrimaries | ( | QColorSpace::Primaries | primariesId | ) |
Sets the primaries to those of the primariesId set.
Definition at line 805 of file qcolorspace.cpp.
References QString::clear(), Custom, QColorSpacePrivate::description, detach(), QColorSpacePrivate::identifyColorSpace(), QColorSpacePrivate::primaries, QColorSpacePrivate, and QColorSpacePrivate::setToXyzMatrix().
Sets the transfer function to transferFunctionTable.
Definition at line 705 of file qcolorspace.cpp.
References QString::clear(), Custom, QColorSpacePrivate::description, detach(), QColorSpacePrivate::gamma, QColorSpacePrivate::identifyColorSpace(), QColorSpacePrivate, QBasicAtomicInteger< T >::ref(), QSharedData::ref, QColorSpacePrivate::setTransferFunction(), and QColorSpacePrivate::setTransferFunctionTable().
void QColorSpace::setTransferFunction | ( | QColorSpace::TransferFunction | transferFunction, |
float | gamma = 0.0f |
||
) |
Sets the transfer function to transferFunction and gamma.
Definition at line 681 of file qcolorspace.cpp.
References QString::clear(), Custom, QColorSpacePrivate::description, detach(), gamma(), QColorSpacePrivate::gamma, QColorSpacePrivate::identifyColorSpace(), QColorSpacePrivate, QColorSpacePrivate::setTransferFunction(), transferFunction(), and QColorSpacePrivate::transferFunction.
Referenced by QPngHandlerPrivate::readPngImage().
void QColorSpace::setTransferFunctions | ( | const QList< uint16_t > & | redTransferFunctionTable, |
const QList< uint16_t > & | greenTransferFunctionTable, | ||
const QList< uint16_t > & | blueTransferFunctionTable | ||
) |
Sets the transfer functions to redTransferFunctionTable, greenTransferFunctionTable and blueTransferFunctionTable.
Definition at line 727 of file qcolorspace.cpp.
References QString::clear(), QColorSpacePrivate::description, detach(), QColorSpacePrivate::gamma, QColorSpacePrivate::identifyColorSpace(), QColorSpacePrivate, QBasicAtomicInteger< T >::ref(), QSharedData::ref, and QColorSpacePrivate::setTransferFunctionTables().
|
inlinenoexcept |
Swaps color space other with this color space.
This operation is very fast and never fails.
Definition at line 78 of file qcolorspace.h.
|
noexcept |
Returns the predefined transfer function of the color space or TransferFunction::Custom
if it doesn't match any of them.
Definition at line 655 of file qcolorspace.cpp.
References Custom, Q_UNLIKELY, and QColorSpacePrivate::transferFunction.
Referenced by QColorSpace(), QRasterPaintEngine::alphaPenBlt(), loadCubeMap(), setTransferFunction(), and withTransferFunction().
QColorTransform QColorSpace::transformationToColorSpace | ( | const QColorSpace & | colorspace | ) | const |
Generates and returns a color space transformation from this color space to colorspace.
Definition at line 981 of file qcolorspace.cpp.
References QExplicitlySharedDataPointer< T >::get(), isValid(), and QColorSpacePrivate::transformationToColorSpace().
Referenced by QImage::convertToColorSpace().
QColorSpace QColorSpace::withTransferFunction | ( | const QList< uint16_t > & | transferFunctionTable | ) | const |
Returns a copy of this color space, except using the transfer function described by transferFunctionTable.
Definition at line 772 of file qcolorspace.cpp.
References isValid(), and out.
QColorSpace QColorSpace::withTransferFunction | ( | QColorSpace::TransferFunction | transferFunction, |
float | gamma = 0.0f |
||
) | const |
Returns a copy of this color space, except using the transfer function transferFunction and gamma.
Definition at line 754 of file qcolorspace.cpp.
References Custom, gamma(), QColorSpacePrivate::gamma, isValid(), out, transferFunction(), and QColorSpacePrivate::transferFunction.
Referenced by QPNGImageWriter::writeImage().
QColorSpace 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 redTransferFunctionTable, greenTransferFunctionTable and blueTransferFunctionTable.
Definition at line 789 of file qcolorspace.cpp.
References isValid(), and out.
|
friend |
Returns true
if colorspace colorSpace1 is not equal to colorspace colorSpace2; otherwise returns false
.
Definition at line 108 of file qcolorspace.h.
|
related |
Writes the given colorSpace to the given stream as an ICC profile.
Definition at line 1043 of file qcolorspace.cpp.
|
friend |
Definition at line 1069 of file qcolorspace.cpp.
|
friend |
Returns true
if colorspace colorSpace1 is equal to colorspace colorSpace2; otherwise returns false
.
Definition at line 106 of file qcolorspace.h.
|
related |
Reads a color space from the given stream and stores it in the given colorSpace.
Definition at line 1059 of file qcolorspace.cpp.
References fromIccProfile().
|
friend |
Definition at line 119 of file qcolorspace.h.
Referenced by QColorSpace(), QColorSpace(), detach(), setPrimaries(), setPrimaries(), setTransferFunction(), setTransferFunction(), and setTransferFunctions().