This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GfColorSpace Class Reference

Basic type: ColorSpace. More...

#include <colorSpace.h>

Public Member Functions

GF_API GfColorSpace (const TfToken &name)
 Construct a GfColorSpace from a name token.
 
GF_API GfColorSpace (const TfToken &name, const GfVec2f &redChroma, const GfVec2f &greenChroma, const GfVec2f &blueChroma, const GfVec2f &whitePoint, float gamma, float linearBias)
 Construct a custom color space from raw values.
 
GF_API GfColorSpace (const TfToken &name, const GfMatrix3f &rgbToXYZ, float gamma, float linearBias)
 Construct a color space from a 3x3 matrix and linearization parameters.
 
GF_API TfToken GetName () const
 Get the name of the color space.
 
GF_API bool operator== (const GfColorSpace &rh) const
 Check if two color spaces are equal.
 
bool operator!= (const GfColorSpace &rh) const
 Check if two color spaces are not equal.
 
GF_API void ConvertRGBSpan (const GfColorSpace &srcColorSpace, TfSpan< float > rgb) const
 Convert in place a packed array of RGB values from one color space to "this" one.
 
GF_API void ConvertRGBASpan (const GfColorSpace &srcColorSpace, TfSpan< float > rgba) const
 Convert in place a packed array of RGBA values from one color space to "this one.
 
GF_API GfColor Convert (const GfColorSpace &srcColorSpace, const GfVec3f &rgb) const
 Convert a rgb triplet in a certain color space to "this" color space.
 
GF_API GfMatrix3f GetRGBToXYZ () const
 Get the RGB to XYZ conversion matrix.
 
GF_API float GetGamma () const
 Get the gamma value of the color space.
 
GF_API float GetLinearBias () const
 Get the linear bias of the color space.
 
GF_API std::pair< float, float > GetTransferFunctionParams () const
 Get the computed K0 and Phi values for use in the transfer function.
 
GF_API std::tuple< GfVec2f, GfVec2f, GfVec2f, GfVec2fGetPrimariesAndWhitePoint () const
 Get the chromaticity coordinates and white point if the color space was constructed from primaries.
 

Static Public Member Functions

static GF_API bool IsValid (const TfToken &name)
 Check if a color space name is valid for constructing a GfColorSpace by name.
 

Friends

class GfColor
 

Detailed Description

Basic type: ColorSpace.

This class represents a colorspace. Color spaces may be created by name, parameterization, or by a 3x3 matrix and a gamma operator.

The parameters used to construct the color space are not available for introspection ~ the color space object is intended for color conversion operations on a GfColor.

The color spaces natively recognized by GfColorSpace are listed in GfColorSpaceNames.

Definition at line 95 of file colorSpace.h.

Constructor & Destructor Documentation

◆ GfColorSpace() [1/3]

GF_API GfColorSpace ( const TfToken name)
explicit

Construct a GfColorSpace from a name token.

Parameters
nameThe name token of the color space.

◆ GfColorSpace() [2/3]

GF_API GfColorSpace ( const TfToken name,
const GfVec2f redChroma,
const GfVec2f greenChroma,
const GfVec2f blueChroma,
const GfVec2f whitePoint,
float  gamma,
float  linearBias 
)
explicit

Construct a custom color space from raw values.

Parameters
nameThe name token of the color space.
redChromaThe red chromaticity coordinates.
greenChromaThe green chromaticity coordinates.
blueChromaThe blue chromaticity coordinates.
whitePointThe white point chromaticity coordinates.
gammaThe gamma value of the log section.
linearBiasThe linear bias of the log section.

◆ GfColorSpace() [3/3]

GF_API GfColorSpace ( const TfToken name,
const GfMatrix3f rgbToXYZ,
float  gamma,
float  linearBias 
)
explicit

Construct a color space from a 3x3 matrix and linearization parameters.

Parameters
nameThe name token of the color space.
rgbToXYZThe RGB to XYZ conversion matrix.
gammaThe gamma value of the log section.
linearBiasThe linear bias of the log section.

Member Function Documentation

◆ Convert()

GF_API GfColor Convert ( const GfColorSpace srcColorSpace,
const GfVec3f rgb 
) const

Convert a rgb triplet in a certain color space to "this" color space.

◆ ConvertRGBASpan()

GF_API void ConvertRGBASpan ( const GfColorSpace srcColorSpace,
TfSpan< float >  rgba 
) const

Convert in place a packed array of RGBA values from one color space to "this one.

Parameters
toThe target color space.
rgbaThe packed array of RGBA values to convert.

◆ ConvertRGBSpan()

GF_API void ConvertRGBSpan ( const GfColorSpace srcColorSpace,
TfSpan< float >  rgb 
) const

Convert in place a packed array of RGB values from one color space to "this" one.

Parameters
toThe target color space.
rgbThe packed array of RGB values to convert.

◆ GetGamma()

GF_API float GetGamma ( ) const

Get the gamma value of the color space.

Returns
The gamma value of the color space.

◆ GetLinearBias()

GF_API float GetLinearBias ( ) const

Get the linear bias of the color space.

Returns
The linear bias of the color space.

◆ GetName()

GF_API TfToken GetName ( ) const

Get the name of the color space.

Returns
The name of the color space.

◆ GetPrimariesAndWhitePoint()

GF_API std::tuple< GfVec2f, GfVec2f, GfVec2f, GfVec2f > GetPrimariesAndWhitePoint ( ) const

Get the chromaticity coordinates and white point if the color space was constructed from primaries.

The primaries and white points will be in the order red, green, blue, white. The values will be valid if the color space was constructed from primaries or a well formed primary matrix.

Returns
The chromaticity coordinates and white point; an empty optional if the color space was not constructed from primaries.

◆ GetRGBToXYZ()

GF_API GfMatrix3f GetRGBToXYZ ( ) const

Get the RGB to XYZ conversion matrix.

Returns
The RGB to XYZ conversion matrix.

◆ GetTransferFunctionParams()

GF_API std::pair< float, float > GetTransferFunctionParams ( ) const

Get the computed K0 and Phi values for use in the transfer function.

◆ IsValid()

static GF_API bool IsValid ( const TfToken name)
static

Check if a color space name is valid for constructing a GfColorSpace by name.

◆ operator!=()

bool operator!= ( const GfColorSpace rh) const
inline

Check if two color spaces are not equal.

Parameters
rhThe rigt-hand side color space.
Returns
True if the color spaces are not equal, false otherwise.

Definition at line 156 of file colorSpace.h.

◆ operator==()

GF_API bool operator== ( const GfColorSpace rh) const

Check if two color spaces are equal.

Parameters
lhThe left-hand side color space.
Returns
True if the color spaces are equal, false otherwise.

Friends And Related Function Documentation

◆ GfColor

friend class GfColor
friend

Definition at line 96 of file colorSpace.h.


The documentation for this class was generated from the following file: