Class: TLabColor

Declaration: LabColor.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TColor

Inherited By:

None.

Purpose:

TLabColor derives from TColor. TLabColor is a class that defines a uniform tristimulus device-independent color space (a calibrated color space) whose values are standardized internationally by the CIE (Commission Internationale de l'Eclairage). Two of the dimensions (a and b) are coordinates on a uniform chromaticity diagram. The L dimension specifies the psychometric lightness. The TLabColor class is used to express colors in a perceptually linear fashion. The perceptual distance between colors is proportional to the geometric distance between colors. The Lab color space is based upon a third-order approximation of the Munsell color system. The TLabColor class has three static fields that are used to define reference white color. Reference white is required to transform a TLabColor to a TXYZColor. Default is reference white D6500. Member functions support correlates of lightness, chroma, saturation, and color-difference. The class also provides arithmetic operators that operate on two colors.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derive new color models from TColor.

Concurrency:

Multithread safe.

Resource Use:

No special requirements.

Member Function: TLabColor::TLabColor

  1. TLabColor ()
  2. TLabColor (const TColor & aColor)
  3. TLabColor (TColorProfile * theDeviceColorProfile)
  4. TLabColor (TristimulusCoord aL, TristimulusCoord aa, TristimulusCoord ab, GIntensity opacity =1.0)
  5. TLabColor (const TLabColor & aLabColor)
  6. TLabColor (TColorProfile * theDeviceColorProfile, TristimulusCoord aL, TristimulusCoord aa, TristimulusCoord ab, GIntensity opacity =1.0)
  7. TLabColor (TLabColor & aLabColor, TxyYColor & aRefWhite)

Interface Category:

API.

Purpose:

  1. Default constructor; it has the default color profile, and color components are not initialized.
  2. Creates a TLabColor from the specified TColor.
  3. Creates a TLabColor with the specified color profile. The color components are not initialized.
  4. Creates a TLabColor with the specified components. It has the default color profile.
  5. Copy constructor.
  6. Creates a TLabColor with the specified components and color profile.
  7. Creates a TLabColor with the specified color profile and the specified components.

Calling Context:

  1. Called by the stream-in operators. You can also call this function directly.
  2. Call this function directly.
  3. Call this function directly.
  4. Call this function directly.
  5. Called to copy an object. You can also call this function directly.
  6. Call this function directly.
  7. Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Member Function: TLabColor::GetComponents

void GetComponents (TristimulusCoord & aL, TristimulusCoord & aa, TristimulusCoord & ab, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the L, a, and b components of this TLabColor and returns them in the specified parameters.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetClampedComponents

void GetClampedComponents (TristimulusCoord & aL, TristimulusCoord & aa, TristimulusCoord & ab, GIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of this TLabColor clamped between 0.0 <= N <= 1.0.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetL

TristimulusCoord GetL () const

Interface Category:

API.

Purpose:

Returns the L component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the L component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::Geta

TristimulusCoord Geta () const

Interface Category:

API.

Purpose:

Returns the a component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the a component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::Getb

TristimulusCoord Getb () const

Interface Category:

API.

Purpose:

Returns the b component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the b component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetColorDifference

GCoordinate GetColorDifference (const TLabColor & color2) const

Interface Category:

API.

Purpose:

Calculates the color difference between this TLabColor and the specified color. The color difference is defined as the sqrt( (L1-L2)^2+(a1-a2)^2+(b1-b2)^2 ).

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the value of the color difference between the two colors.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::SetComponents

void SetComponents (TristimulusCoord aL, TristimulusCoord aa, TristimulusCoord ab, GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the components of this TLabColor to the specified parameters.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operatorTRGBColor

virtual operator TRGBColor () const

Interface Category:

API.

Purpose:

Casts the TLabColor to a TRGBColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a TRGBColor that corresponds to the LabColor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operatorTXYZColor

virtual operator TXYZColor () const

Interface Category:

API.

Purpose:

Casts this TLabColor to a TXYZColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a TXYZColor that corresponds to this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operator=

  1. TLabColor & operator =(const TLabColor & aSource)
  2. TColor & operator =(const TColor & aSource)

Interface Category:

API.

Purpose:

  1. Assignment operator.
  2. Assignment operator that casts the specified operand to a TLabColor.

Calling Context:

  1. Called when an object is assigned to another compatible object.
  2. Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operator+

  1. TLabColor operator + (const TLabColor & aColor2) const
  2. TLabColor operator + (const float aScalar) const

Interface Category:

API.

Purpose:

  1. Adds the components of the two TLabColors together.
  2. Adds the specified scalar to each component of this TLabColor.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. Returns a new color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The values of the components are not clamped to the range 0.0 <= N <= 1.0.

Member Function: TLabColor::operator-

  1. TLabColor operator -(const TLabColor & aColor2) const
  2. TLabColor operator -(const float aScalar) const

Interface Category:

API.

Purpose:

  1. Subtracts the components of the specified color from this TLabColor.
  2. Subtracts the specified scalar from each component of this TLabColor.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. Returns a new color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The values of the components are not clamped to the range 0.0 <= N <= 1.0.

Member Function: TLabColor::operator*

  1. TLabColor operator * (const float aScalar) const
  2. TLabColor operator * (const TLabColor & aColor2) const

Interface Category:

API.

Purpose:

  1. Multiplies each component of this TLabColor by the specified scalar.
  2. Multiplies the components of this TLabColor by the components of the specified color.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns a new color with the new components.
  2. Returns a new color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The values of the components are not clamped to the range 0.0 <= N <= 1.0.

Member Function: TLabColor::operator/=

TLabColor & operator /= (const float aScalar)

Interface Category:

API.

Purpose:

Divides the components of this TLabColor by the specified scalar and assigns the new values to the respective components.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns this color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::operator+=

  1. TLabColor & operator += (const float aScalar)
  2. TLabColor & operator += (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

  1. Adds the specified scalar to the components of this TLabColor and assigns the new values to the respective components.
  2. Adds the specified colors to the components of this TLabColor and assigns the new values to the respective components.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns this color with the new components.
  2. Returns this color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::operator-=

  1. TLabColor & operator -=(const float aScalar)
  2. TLabColor & operator -=(const TLabColor & aColor2)

Interface Category:

API.

Purpose:

  1. Subtracts the specified scalar from the components of this TLabColor and assigns the new values to the respective components.
  2. Subtracts the specified scalar from the components of this TLabColor and assigns the new values to the respective components.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns this color with the new components.
  2. Returns this color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::operator*=

TLabColor & operator *= (const float aScalar)

Interface Category:

API.

Purpose:

Multiplies the components of this TLabColor by the specified scalar and assigns the new values to the respective components.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns this color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::operator/

TLabColor operator / (const float aScalar) const

Interface Category:

API.

Purpose:

Divides each component in this TLabColor by the specified scalar.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns a color with the new components.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::FuzzyCompare

  1. bool FuzzyCompare (const TLabColor & aLabColor, float acceptableErrorPerComponent =0.0001) const
  2. bool FuzzyCompare (const TLabColor & aLabColor, float errOpacity, float errL, float erra, float errb) const

Interface Category:

API.

Purpose:

  1. Compares this TLabColor and the specified color with reference to the specified tolerance. It takes the absolute difference between the components of the color and compares them to a known value.
  2. Compares this TLabColor and the specified color to a given accuracy on a component by component level.

Calling Context:

  1. Call this operator directly.
  2. Call this operator directly.

Parameters:

Return Value:

  1. Returns true if the two colors are equal with reference to the specified tolerance.
  2. Returns true if the two colors are equal with reference to the specified tolerance.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::LinearInterpolate

void LinearInterpolate (const float aWeight, const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Makes a weighted linear interpolation of each component of this TLabColor. The interpolation is returned in this color. The interpolation that is done for each component is (using L as an example) given by L1 =L1 + (L2 -L1) * Weight.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::AddAndPin

void AddAndPin (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Adds the specified color to this TLabColor and then clamps the resulting values of the components.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::SubtractAndPin

void SubtractAndPin (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Subtracts the specified color from this TLabColor and then clamps the resulting values of the components.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Maximum

void Maximum (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Determines the maximum of individual components of this TLabColor and the specified color. It sets the components of this color to the resulting maximum values.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Minimum

void Minimum (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Determines the maximum of individual components of this TLabColor and the specified color. It sets the components of this color to the resulting maximum values.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Blend

void Blend (const TLabColor & aColor2)

Interface Category:

API.

Purpose:

Averages the individual components of the two colors and returns them in this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Invert

void Invert ()

Interface Category:

API.

Purpose:

Inverts this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Clamp

void Clamp ()

Interface Category:

API.

Purpose:

Clamps the components of this TLabColor between 0.0 <= N <= 1.0. If a value is less than 0.0, it is set to 0.0, and if it is greater than 1.1, it is set to 1.0.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::Scale

void Scale ()

Interface Category:

API.

Purpose:

Scale this TLabColor to 1.0. If all of the color's components are between 0.0 <= N <= 1.0, the color is untouched. If there are components with values greater than 1.0, then the largest component is used to renormalize the color. If any of the color's components are less than 0.0, they set to 0.0.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

The color's opacity is set to 1.0.

Member Function: TLabColor::TemporaryTypeID

virtual TemporaryColorClassID TemporaryTypeID () const

Interface Category:

API.

Purpose:

Determines the type of color that the derived class of TLabColor represents..

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns TColor::kTLabColor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::SetRefWhite

  1. void SetRefWhite (TxyYColor & aRefWhite)
  2. void SetRefWhite (ChromaCoord x, ChromaCoord y, TristimulusCoord Y)
  3. void SetRefWhite (Temperature aTemperature)

Interface Category:

API.

Purpose:

  1. Sets the reference white of the TLabColor class to the specified TxyYColor.
  2. Sets the reference white of the TLabColor class to the TxyYColor defined by the specified components.
  3. Sets the reference white of the TLabColor class to the specified color temperature.

Calling Context:

  1. Call this function directly.
  2. Call this function directly.
  3. Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetRefWhite

void GetRefWhite (TxyYColor & aRefWhite)

Interface Category:

API.

Purpose:

Returns the xyYColor that is the reference white of the TLabColor class in the specified parameter.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetHueDifference

GCoordinate GetHueDifference (const TLabColor & Color2)

Interface Category:

API.

Purpose:

Provides the numeric difference in hue between two colors expressed in Lab space. The difference is calculated between this TLabColor and the color (Color2) passed in as a parameter. Hue difference is defined as a function of the total color difference, minus the correlate of lightness, minus the correlate of chroma.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the difference in hue between the two colors.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetHueAngle

GCoordinate GetHueAngle ()

Interface Category:

API.

Purpose:

Provides the hue angle of the color. Hue angle is a useful quantity for specifying hue numerically. It is given, in this case, by arctan(b/a).

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the numeric value for the hue angle.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetCorrelatesOfChroma

GCoordinate GetCorrelatesOfChroma ()

Interface Category:

API.

Purpose:

Calculates the correlate of chroma, which is the square root of the sum of the squares of a and b.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the numeric value of the correlate of chroma.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetCorrelateOfLightness

GCoordinate GetCorrelateOfLightness ()

Interface Category:

API.

Purpose:

Calculates the correlate of lightness, which is usually defined to be the L component of the color.

Calling Context:

Called directly to obtain the correlate of lightness.

Parameters:

Return Value:

Returns the correlate of lightness for this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::SetL

void SetL (TristimulusCoord aL)

Interface Category:

API.

Purpose:

Sets the L component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::Seta

void Seta (TristimulusCoord aa)

Interface Category:

API.

Purpose:

Sets the a component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::Setb

void Setb (TristimulusCoord ab)

Interface Category:

API.

Purpose:

Sets the b component of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::~TLabColor

virtual ~ TLabColor ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::ClampOpacity

void ClampOpacity ()

Interface Category:

API.

Purpose:

Pins the opacity of this TLabColor to the range 0.0 to 1.0.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::SetOpacity

void SetOpacity (GIntensity opacity =1.0)

Interface Category:

API.

Purpose:

Sets the opacity of this TLabColor to the specified value.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetClampedOpacity

GIntensity GetClampedOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this TLabColor and pins the value to the range 0.0 to 1.0.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The clamped opacity.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TLabColor::GetOpacity

GIntensity GetOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this TLabColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The opacity that can be outside the range 0.0 to 1.0.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.