QColorSpace 类提供色彩空间的抽象。 更多...
| 头: |
#include <QColorSpace>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
|
| qmake: |
QT += gui
|
(从 6.8 起)
枚举类
|
ColorModel { Undefined, Rgb, Gray, Cmyk } |
| enum | NamedColorSpace { SRgb, SRgbLinear, AdobeRgb, DisplayP3, ProPhotoRgb, …, Bt2100Hlg } |
| 枚举类 | Primaries { Custom, SRgb, AdobeRgb, DciP3D65, ProPhotoRgb, Bt2020 } |
| 枚举类 | TransferFunction { Custom, Linear, Gamma, SRgb, ProPhotoRgb, …, Hlg } |
(从 6.8 起)
枚举类
|
TransformModel { ThreeComponentMatrix, ElementListProcessing } |
| QColorSpace () | |
| QColorSpace (QColorSpace::NamedColorSpace namedColorSpace ) | |
(从 6.1 起)
|
QColorSpace (QColorSpace::Primaries gamut , const QList<uint16_t> & transferFunctionTable ) |
| QColorSpace (QColorSpace::Primaries primaries , float gamma ) | |
(从 6.8 起)
|
QColorSpace (QPointF whitePoint , const QList<uint16_t> & transferFunctionTable ) |
| QColorSpace (QColorSpace::Primaries primaries , QColorSpace::TransferFunction transferFunction , float gamma = 0.0f) | |
(从 6.8 起)
|
QColorSpace (QPointF whitePoint , QColorSpace::TransferFunction transferFunction , float gamma = 0.0f) |
(从 6.1 起)
|
QColorSpace (const QPointF & whitePoint , const QPointF & redPoint , const QPointF & greenPoint , const QPointF & bluePoint , const QList<uint16_t> & transferFunctionTable ) |
| QColorSpace (const QPointF & whitePoint , const QPointF & redPoint , const QPointF & greenPoint , const QPointF & bluePoint , QColorSpace::TransferFunction transferFunction , float gamma = 0.0f) | |
(从 6.1 起)
|
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 ) |
(从 6.8 起)
QColorSpace::ColorModel
|
colorModel () const |
(从 6.2 起)
QString
|
description () const |
| float | gamma () const |
| QByteArray | iccProfile () const |
| bool | isValid () const |
(从 6.8 起)
bool
|
isValidTarget () const |
| QColorSpace::Primaries | primaries () const |
(从 6.2 起)
void
|
setDescription (const QString & description ) |
| void | setPrimaries (QColorSpace::Primaries primariesId ) |
| void | setPrimaries (const QPointF & whitePoint , const QPointF & redPoint , const QPointF & greenPoint , const QPointF & bluePoint ) |
(从 6.1 起)
void
|
setTransferFunction (const QList<uint16_t> & transferFunctionTable ) |
| void | setTransferFunction (QColorSpace::TransferFunction transferFunction , float gamma = 0.0f) |
(从 6.1 起)
void
|
setTransferFunctions (const QList<uint16_t> & redTransferFunctionTable , const QList<uint16_t> & greenTransferFunctionTable , const QList<uint16_t> & blueTransferFunctionTable ) |
(从 6.8 起)
void
|
setWhitePoint (QPointF whitePoint ) |
| void | swap (QColorSpace & other ) |
| QColorSpace::TransferFunction | transferFunction () const |
(从 6.8 起)
QColorSpace::TransformModel
|
transformModel () const |
| QColorTransform | transformationToColorSpace (const QColorSpace & colorspace ) const |
(从 6.8 起)
QPointF
|
whitePoint () const |
(从 6.1 起)
QColorSpace
|
withTransferFunction (const QList<uint16_t> & transferFunctionTable ) const |
| QColorSpace | withTransferFunction (QColorSpace::TransferFunction transferFunction , float gamma = 0.0f) const |
(从 6.1 起)
QColorSpace
|
withTransferFunctions (const QList<uint16_t> & redTransferFunctionTable , const QList<uint16_t> & greenTransferFunctionTable , const QList<uint16_t> & blueTransferFunctionTable ) const |
| QVariant | operator QVariant () const |
| QColorSpace | fromIccProfile (const QByteArray & iccProfile ) |
| bool | operator!= (const QColorSpace & colorSpace1 , const QColorSpace & colorSpace2 ) |
| QDataStream & | operator<< (QDataStream & stream , const QColorSpace & colorSpace ) |
| bool | operator== (const QColorSpace & colorSpace1 , const QColorSpace & colorSpace2 ) |
| QDataStream & | operator>> (QDataStream & stream , QColorSpace & colorSpace ) |
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 for ColorModel::Rgb color spaces 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. For grayscale color spaces, only a single white primary is needed. 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.
[since 6.8]
enum class QColorSpace::
ColorModel
Defines the color model used by the color space data.
| 常量 | 值 | 描述 |
|---|---|---|
QColorSpace::ColorModel::Undefined
|
0
|
No color model |
QColorSpace::ColorModel::Rgb
|
1
|
An RGB color model with red, green, and blue colors. Can apply to RGB and grayscale data. |
QColorSpace::ColorModel::Gray
|
2
|
A gray scale color model. Can only apply to grayscale data. |
QColorSpace::ColorModel::Cmyk
|
3
|
Can only represent color data defined with cyan, magenta, yellow, and black colors. In effect only QImage::Format_CMYK32. Note Cmyk color spaces will be TransformModel::ElementListProcessing . |
该枚举在 Qt 6.8 引入。
Predefined color spaces.
| 常量 | 值 | 描述 |
|---|---|---|
QColorSpace::SRgb
|
1
|
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. ICC registration of sRGB . |
QColorSpace::SRgbLinear
|
2
|
The sRGB color space with linear gamma. Useful for gamma-corrected blending. |
QColorSpace::AdobeRgb
|
3
|
The Adobe RGB color space is a classic wide-gamut color space, using a gamma of 2.2. ICC registration of Adobe RGB (1998) |
QColorSpace::DisplayP3
|
4
|
A color-space using the primaries of DCI-P3, but with the whitepoint and transfer function of sRGB. Common in modern wide-gamut screens. ICC registration of DCI-P3 |
QColorSpace::ProPhotoRgb
|
5
|
The Pro Photo RGB color space, also known as ROMM RGB is a very wide gamut color space. ICC registration of ROMM RGB |
QColorSpace::Bt2020 (since Qt 6.8)
|
6
|
BT.2020, also known as Rec.2020 is a basic colorspace of HDR TVs. ICC registration of BT.2020 |
QColorSpace::Bt2100Pq (since Qt 6.8)
|
7
|
BT.2100(PQ), also known as Rec.2100 or HDR10 is an HDR encoding with the same primaries as Bt2020 but using the Perceptual Quantizer transfer function. ICC registration of BT.2100 |
QColorSpace::Bt2100Hlg (since Qt 6.8)
|
8
|
BT.2100 (HLG) is an HDR encoding with the same primaries as Bt2020 but using the Hybrid Log-Gamma transfer function. |
预定义的首要颜色集。
| 常量 | 值 | 描述 |
|---|---|---|
QColorSpace::Primaries::Custom
|
0
|
The primaries are undefined or does not match any predefined sets. |
QColorSpace::Primaries::SRgb
|
1
|
The sRGB primaries |
QColorSpace::Primaries::AdobeRgb
|
2
|
The Adobe RGB primaries |
QColorSpace::Primaries::DciP3D65
|
3
|
The DCI-P3 primaries with the D65 whitepoint |
QColorSpace::Primaries::ProPhotoRgb
|
4
|
The ProPhoto RGB primaries with the D50 whitepoint |
QColorSpace::Primaries::Bt2020 (since Qt 6.8)
|
5
|
The BT.2020 primaries with a D65 whitepoint |
Predefined transfer functions or gamma curves.
| 常量 | 值 | 描述 |
|---|---|---|
QColorSpace::TransferFunction::Custom
|
0
|
The custom or null transfer function |
QColorSpace::TransferFunction::Linear
|
1
|
The linear transfer functions |
QColorSpace::TransferFunction::Gamma
|
2
|
A transfer function that is a real gamma curve based on the value of gamma () |
QColorSpace::TransferFunction::SRgb
|
3
|
The sRGB transfer function, composed of linear and gamma parts |
QColorSpace::TransferFunction::ProPhotoRgb
|
4
|
The ProPhoto RGB transfer function, composed of linear and gamma parts |
QColorSpace::TransferFunction::Bt2020 (since Qt 6.8)
|
5
|
The BT.2020 transfer function, composited of linear and gamma parts |
QColorSpace::TransferFunction::St2084 (since Qt 6.8)
|
6
|
The SMPTE ST 2084 transfer function, also known Perceptual Quantizer(PQ). |
QColorSpace::TransferFunction::Hlg (since Qt 6.8)
|
7
|
The Hybrid log-gamma transfer function. |
[since 6.8]
enum class QColorSpace::
TransformModel
Defines the processing model used for color space transforms.
| 常量 | 值 | 描述 |
|---|---|---|
QColorSpace::TransformModel::ThreeComponentMatrix
|
0
|
The transform consist of a matrix calculated from primaries and set of transfer functions for each color channel. This is very fast and used by all predefined color spaces. Any color space on this form is reversible and always both valid sources and targets. |
QColorSpace::TransformModel::ElementListProcessing
|
1
|
The transforms are one or two lists of processing elements that can do many things, each list only process either to the connection color space or from it. This is very flexible, but rather slow, and can only be set by reading ICC profiles (See fromIccProfile ()). Since the two lists are separate a color space on this form can be a valid source, but not necessarily also a valid target. When changing either primaries or transfer function on a color space on this type it will reset to an empty ThreeComponentMatrix form. |
该枚举在 Qt 6.8 引入。
[noexcept]
QColorSpace::
QColorSpace
()
Creates a new colorspace object that represents an undefined and invalid colorspace.
Creates a new colorspace object that represents a namedColorSpace .
[since 6.1]
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.
该函数在 Qt 6.1 引入。
Creates a custom color space with the primaries primaries , using a gamma transfer function of gamma .
[explicit, since 6.8]
QColorSpace::
QColorSpace
(
QPointF
whitePoint
, const
QList
<
uint16_t
> &
transferFunctionTable
)
Creates a custom grayscale color space with white point whitePoint , and using the custom transfer function described by transferFunctionTable .
该函数在 Qt 6.8 引入。
Creates a custom color space with the primaries primaries , using the transfer function transferFunction and optionally gamma .
[explicit, since 6.8]
QColorSpace::
QColorSpace
(
QPointF
whitePoint
,
QColorSpace::TransferFunction
transferFunction
,
float
gamma
= 0.0f)
Creates a custom grayscale color space with the white point whitePoint , using the transfer function transferFunction and optionally gamma .
该函数在 Qt 6.8 引入。
[since 6.1]
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 .
该函数在 Qt 6.1 引入。
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 .
[since 6.1]
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 ,和 blueTransferFunctionTable .
该函数在 Qt 6.1 引入。
[noexcept, since 6.8]
QColorSpace::ColorModel
QColorSpace::
colorModel
() const
Returns the color model this color space can represent
该函数在 Qt 6.8 引入。
[noexcept, since 6.2]
QString
QColorSpace::
description
() const
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.
该函数在 Qt 6.2 引入。
另请参阅 setDescription ().
[static]
QColorSpace
QColorSpace::
fromIccProfile
(const
QByteArray
&
iccProfile
)
创建 QColorSpace from ICC profile iccProfile .
注意: Not all ICC profiles are supported. QColorSpace only supports RGB or Gray ICC profiles.
If the ICC profile is not supported an invalid QColorSpace is returned where you can still read the original ICC profile using iccProfile ().
另请参阅 iccProfile ().
[noexcept]
float
QColorSpace::
gamma
() const
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.
另请参阅 transferFunction ().
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.
注意: Even invalid color spaces may return the ICC profile if they were generated from one, to allow applications to implement wider support themselves.
另请参阅 fromIccProfile ().
[noexcept]
bool
QColorSpace::
isValid
() const
返回
true
if the color space is valid. For a color space with
TransformModel::ThreeComponentMatrix
that means both primaries and transfer functions set, and implies
isValidTarget
(). For a color space with
TransformModel::ElementListProcessing
it means it has a valid source transform, to check if it also a valid target color space use
isValidTarget
().
另请参阅 isValidTarget ().
[noexcept, since 6.8]
bool
QColorSpace::
isValidTarget
() const
返回
true
if the color space is a valid target color space.
该函数在 Qt 6.8 引入。
[noexcept]
QColorSpace::Primaries
QColorSpace::
primaries
() const
Returns the predefined primaries of the color space or
primaries::Custom
if it doesn't match any of them.
另请参阅 setPrimaries ().
[since 6.2]
void
QColorSpace::
setDescription
(const
QString
&
description
)
Sets the name or short description of the color space to description .
If set to empty description () will return original or guessed descriptions instead.
该函数在 Qt 6.2 引入。
另请参阅 description ().
Sets the primaries to those of the primariesId set.
另请参阅 primaries ().
Set primaries to the chromaticities of whitePoint , redPoint , greenPoint and bluePoint .
另请参阅 primaries ().
[since 6.1]
void
QColorSpace::
setTransferFunction
(const
QList
<
uint16_t
> &
transferFunctionTable
)
Sets the transfer function to transferFunctionTable .
该函数在 Qt 6.1 引入。
另请参阅 transferFunction () 和 withTransferFunction ().
Sets the transfer function to transferFunction and gamma .
另请参阅 transferFunction (), gamma (),和 withTransferFunction ().
[since 6.1]
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 .
该函数在 Qt 6.1 引入。
另请参阅 withTransferFunctions ().
[since 6.8]
void
QColorSpace::
setWhitePoint
(
QPointF
whitePoint
)
Sets the white point to used for this color space to whitePoint .
该函数在 Qt 6.8 引入。
另请参阅 whitePoint ().
[noexcept]
void
QColorSpace::
swap
(
QColorSpace
&
other
)
Swaps this color space with other 。此操作非常快且从不失败。
[noexcept]
QColorSpace::TransferFunction
QColorSpace::
transferFunction
() const
Returns the predefined transfer function of the color space or
TransferFunction::Custom
if it doesn't match any of them.
另请参阅 gamma (), setTransferFunction (),和 withTransferFunction ().
[noexcept, since 6.8]
QColorSpace::TransformModel
QColorSpace::
transformModel
() const
Returns the transfrom processing model used for this color space.
该函数在 Qt 6.8 引入。
Generates and returns a color space transformation from this color space to colorspace .
[since 6.8]
QPointF
QColorSpace::
whitePoint
() const
Returns the white point used for this color space. Returns a null QPointF if not defined.
该函数在 Qt 6.8 引入。
另请参阅 setWhitePoint ().
[since 6.1]
QColorSpace
QColorSpace::
withTransferFunction
(const
QList
<
uint16_t
> &
transferFunctionTable
) const
Returns a copy of this color space, except using the transfer function described by transferFunctionTable .
该函数在 Qt 6.1 引入。
另请参阅 transferFunction () 和 setTransferFunction ().
Returns a copy of this color space, except using the transfer function transferFunction and gamma .
另请参阅 transferFunction (), gamma (),和 setTransferFunction ().
[since 6.1]
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 .
该函数在 Qt 6.1 引入。
另请参阅 setTransferFunctions ().
Returns the color space as a QVariant .
返回
true
if colorspace
colorSpace1
is not equal to colorspace
colorSpace2
;否则返回
false
写入给定 colorSpace 到给定 stream as an ICC profile.
另请参阅 QColorSpace::iccProfile () 和 序列化 Qt 数据类型 .
返回
true
if colorspace
colorSpace1
is equal to colorspace
colorSpace2
;否则返回
false
Reads a color space from the given stream 并把它存储在给定 colorSpace .
另请参阅 QColorSpace::fromIccProfile () 和 序列化 Qt 数据类型 .