QColorSpace¶
The
QColorSpace
class provides a color space abstraction. More…
New in version 5.14.
Synopsis¶
Functions¶
def
__eq__
(, colorSpace2)def
__ne__
(, colorSpace2)def
gamma
()def
iccProfile
()def
isValid
()def
primaries
()def
setPrimaries
(primariesId)def
setPrimaries
(whitePoint, redPoint, greenPoint, bluePoint)def
setTransferFunction
(transferFunction[, gamma=0.0f])def
swap
(colorSpace)def
transferFunction
()def
withTransferFunction
(transferFunction[, gamma=0.0f])
Static functions¶
def
fromIccProfile
(iccProfile)
Detailed Description¶
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 expressable 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.
- class PySide2.QtGui.QColorSpace¶
PySide2.QtGui.QColorSpace(namedColorSpace)
PySide2.QtGui.QColorSpace(primaries, transferFunction[, gamma=0.0f])
PySide2.QtGui.QColorSpace(primaries, gamma)
PySide2.QtGui.QColorSpace(colorSpace)
PySide2.QtGui.QColorSpace(whitePoint, redPoint, greenPoint, bluePoint, transferFunction[, gamma=0.0f])
- param greenPoint:
- param primaries:
- param transferFunction:
- param redPoint:
- param colorSpace:
- param namedColorSpace:
- param gamma:
float
- param bluePoint:
- param whitePoint:
Creates a new colorspace object that represents an undefined and invalid colorspace.
Creates a new colorspace object that represents a
namedColorSpace
.Creates a custom color space with the primaries
primaries
, using the transfer functiontransferFunction
and optionallygamma
.Creates a custom color space with the primaries
primaries
, using a gamma transfer function ofgamma
.Creates a custom colorspace with a primaries based on the chromaticities of the primary colors
whitePoint
,redPoint
,greenPoint
andbluePoint
, and using the transfer functiontransferFunction
and optionallygamma
.
- PySide2.QtGui.QColorSpace.NamedColorSpace¶
Predefined color spaces.
Constant
Description
QColorSpace.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. ICC registration of sRGB .
QColorSpace.SRgbLinear
The sRGB color space with linear gamma. Useful for gamma-corrected blending.
QColorSpace.AdobeRgb
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
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
The Pro Photo RGB color space, also known as ROMM RGB is a very wide gamut color space. ICC registration of ROMM RGB
- PySide2.QtGui.QColorSpace.Primaries¶
Predefined sets of primary colors.
Constant
Description
QColorSpace.Primaries.Custom
The primaries are undefined or does not match any predefined sets.
QColorSpace.Primaries.SRgb
The sRGB primaries
QColorSpace.Primaries.AdobeRgb
The Adobe RGB primaries
QColorSpace.Primaries.DciP3D65
The DCI-P3 primaries with the D65 whitepoint
QColorSpace.Primaries.ProPhotoRgb
The ProPhoto RGB primaries with the D50 whitepoint
- PySide2.QtGui.QColorSpace.TransferFunction¶
Predefined transfer functions or gamma curves.
Constant
Description
QColorSpace.TransferFunction.Custom
The custom or null transfer function
QColorSpace.TransferFunction.Linear
The linear transfer functions
QColorSpace.TransferFunction.Gamma
A transfer function that is a real gamma curve based on the value of
gamma()
QColorSpace.TransferFunction.SRgb
The sRGB transfer function, composed of linear and gamma parts
QColorSpace.TransferFunction.ProPhotoRgb
The ProPhoto RGB transfer function, composed of linear and gamma parts
- static PySide2.QtGui.QColorSpace.fromIccProfile(iccProfile)¶
- Parameters:
iccProfile –
PySide2.QtCore.QByteArray
- Return type:
Creates a
QColorSpace
from ICC profileiccProfile
.Note
Not all ICC profiles are supported.
QColorSpace
only supports RGB-XYZ ICC profiles that are three-component matrix-based.If the ICC profile is not supported an invalid
QColorSpace
is returned where you can still read the original ICC profile usingiccProfile()
.See also
- PySide2.QtGui.QColorSpace.gamma()¶
- Return type:
float
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.See also
- PySide2.QtGui.QColorSpace.iccProfile()¶
- Return type:
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.
Note
Even invalid color spaces may return the ICC profile if they were generated from one, to allow applications to implement wider support themselves.
See also
- PySide2.QtGui.QColorSpace.isValid()¶
- Return type:
bool
Returns
true
if the color space is valid.
- PySide2.QtGui.QColorSpace.__ne__(colorSpace2)¶
- Parameters:
colorSpace2 –
PySide2.QtGui.QColorSpace
- Return type:
bool
- PySide2.QtGui.QColorSpace.__eq__(colorSpace2)¶
- Parameters:
colorSpace2 –
PySide2.QtGui.QColorSpace
- Return type:
bool
- PySide2.QtGui.QColorSpace.primaries()¶
- Return type:
Returns the predefined primaries of the color space or
primaries::Custom
if it doesn’t match any of them.See also
- PySide2.QtGui.QColorSpace.setPrimaries(primariesId)¶
- Parameters:
primariesId –
Primaries
Sets the primaries to those of the
primariesId
set.See also
- PySide2.QtGui.QColorSpace.setPrimaries(whitePoint, redPoint, greenPoint, bluePoint)
- Parameters:
whitePoint –
PySide2.QtCore.QPointF
redPoint –
PySide2.QtCore.QPointF
greenPoint –
PySide2.QtCore.QPointF
bluePoint –
PySide2.QtCore.QPointF
Set primaries to the chromaticities of
whitePoint
,redPoint
,greenPoint
andbluePoint
.See also
- PySide2.QtGui.QColorSpace.setTransferFunction(transferFunction[, gamma=0.0f])¶
- Parameters:
transferFunction –
TransferFunction
gamma – float
Sets the transfer function to
transferFunction
andgamma
.
- PySide2.QtGui.QColorSpace.swap(colorSpace)¶
- Parameters:
colorSpace –
PySide2.QtGui.QColorSpace
Swaps color space
other
with this color space. This operation is very fast and never fails.
- PySide2.QtGui.QColorSpace.transferFunction()¶
- Return type:
Returns the predefined transfer function of the color space or
TransferFunction::Custom
if it doesn’t match any of them.
- PySide2.QtGui.QColorSpace.withTransferFunction(transferFunction[, gamma=0.0f])¶
- Parameters:
transferFunction –
TransferFunction
gamma – float
- Return type:
Returns a copy of this color space, except using the transfer function
transferFunction
andgamma
.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.