Class: TRGBCompactColor

Declaration: RGBCompactColor.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TColor

Inherited By:

None.

Purpose:

TCompactRGBColor is derived from TColor. The class defines the Cartesian coordinate-based color model of red, green, and blue. The RGB primaries, which are additive, are used for most color monitors and color raster graphic systems. Because most RGB monitors emit radiation, the color perceived at the eye is the sum of the three primaries. Values of the primaries are constrained to the range between 0 and 255, inclusive. Member functions are provided to clamp the RGB primaries to this range. The RGB color model is uncalibrated; therefore, RGB colors must be defined with respect to a particular color device through a color profile. The class 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.

Other Considerations:

None.

Member Function: TRGBCompactColor::TRGBCompactColor

  1. TRGBCompactColor ()
  2. TRGBCompactColor (const TColor & aColor)
  3. TRGBCompactColor (TColorProfile * theDeviceColorProfile)
  4. TRGBCompactColor (CharIntensity aRed, CharIntensity aGreen, CharIntensity aBlue, CharIntensity opacity =255)
  5. TRGBCompactColor (const TRGBCompactColor & aRGBCompactColor)
  6. TRGBCompactColor (TColorProfile * theDeviceColorProfile, CharIntensity aRed, CharIntensity aGreen, CharIntensity aBlue, CharIntensity opacity =255)

Interface Category:

API.

Purpose:

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

Calling Context:

  1. Called by the stream-in operators and 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.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::~TRGBCompactColor

virtual ~ TRGBCompactColor ()

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: TRGBCompactColor::GetComponents

void GetComponents (CharIntensity & aRed, CharIntensity & aGreen, CharIntensity & aBlue, CharIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of the TCompactRGBColor.

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: TRGBCompactColor::GetClampedComponents

void GetClampedComponents (CharIntensity & aRed, CharIntensity & aGreen, CharIntensity & aBlue, CharIntensity & opacity) const

Interface Category:

API.

Purpose:

Gets the components of this TCompactRGBColor clamped between 0 <= N <= 255.

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: TRGBCompactColor::GetRed

CharIntensity GetRed () const

Interface Category:

API.

Purpose:

Gets the red component of this TRGBCompactColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the red component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::GetGreen

CharIntensity GetGreen () const

Interface Category:

API.

Purpose:

Gets the green component of this TRGBCompactColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the green component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::GetBlue

CharIntensity GetBlue () const

Interface Category:

API.

Purpose:

Gets the blue component of this TRGBCompactColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the blue component of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::GetOpacity

GIntensity GetOpacity () const

Interface Category:

API.

Purpose:

Gets the opacity of this TRGBCompactColor.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns the opacity of the color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::GetColorDifference

float GetColorDifference (const TRGBCompactColor & aColor2) const

Interface Category:

API.

Purpose:

Calculates the color difference between this TRGBCompactColor and the specified one. The color difference is defined as the sqrt( (R1-R2)^2+(G1-G2)^2+(B1-B2)^2 ).

Calling Context:

Call this function directly.

Parameters:

Return Value:

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: TRGBCompactColor::SetComponents

void SetComponents (CharIntensity aRed, CharIntensity aGreen, CharIntensity aBlue, CharIntensity opacity =255)

Interface Category:

API.

Purpose:

Sets the components of this TRGBCompactColor with the specified values.

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: TRGBCompactColor::SetRed

void SetRed (CharIntensity aRed)

Interface Category:

API.

Purpose:

Sets the red component of this TRGBCompactColor.

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: TRGBCompactColor::SetGreen

void SetGreen (CharIntensity aGreen)

Interface Category:

API.

Purpose:

Sets the green component of this TRGBCompactColor.

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: TRGBCompactColor::SetBlue

void SetBlue (CharIntensity aBlue)

Interface Category:

API.

Purpose:

Sets the blue component of this TRGBCompactColor.

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: TRGBCompactColor::SetOpacity

void SetOpacity (CharIntensity opacity =255)

Interface Category:

API.

Purpose:

Sets the opacity of this TRGBCompactColor.

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: TRGBCompactColor::ClampOpacity

void ClampOpacity ()

Interface Category:

API.

Purpose:

Pins the opacity of this TRGBCompactColor to the range 0 <= N <= 255.

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: TRGBCompactColor::GetClampedOpacity

GIntensity GetClampedOpacity () const

Interface Category:

API.

Purpose:

Returns the opacity of this TRGBCompactColor and pins the value to the range 0 <= N <= 255.

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: TRGBCompactColor::operatorTRGBColor

virtual operator TRGBColor () const

Interface Category:

API.

Purpose:

Casts this TRGBCompactColor to a TRGBColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns an RGBColor that corresponds with this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::operatorTXYZColor

virtual operator TXYZColor () const

Interface Category:

API.

Purpose:

Casts this TRGBCompactColor to a TXYZColor.

Calling Context:

Call this operator directly.

Parameters:

Return Value:

Returns a XYZColor that corresponds with this color.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::operator=

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

Interface Category:

API.

Purpose:

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

Calling Context:

  1. Called when an object is assigned to another compatible object.
  2. Called when a TColor object is assigned to a TRGBCompactColor 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: TRGBCompactColor::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: TRGBCompactColor::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: TRGBCompactColor::operator+

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

Interface Category:

API.

Purpose:

  1. Adds the components of the two TRGBCompactColors together.
  2. Adds the specified scalar to each component of this TRGBCompactColor.

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:

None.

Member Function: TRGBCompactColor::operator-

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

Interface Category:

API.

Purpose:

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

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:

None.

Member Function: TRGBCompactColor::operator*

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

Interface Category:

API.

Purpose:

  1. Multiplies each component of this TRGBCompactColor by the specified scalar.
  2. Multiplies the components of this TRGBCompactColor 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 <= N <= 255.

Member Function: TRGBCompactColor::operator/

TRGBCompactColor operator / (const float aScalar) const

Interface Category:

API.

Purpose:

Divides the components of this TRGBCompactColor by the specified scalar.

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:

None.

Member Function: TRGBCompactColor::operator+=

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

Interface Category:

API.

Purpose:

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

Calling Context:

  1. Call this operator directly.
  2. 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:

None.

Member Function: TRGBCompactColor::operator-=

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

Interface Category:

API.

Purpose:

  1. Subtracts the specified scalar from the components of this TRGBCompactColor and assigns the new values to the respective components.
  2. Subtracts the specified scalar from the components of this TRGBCompactColor 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:

None.

Member Function: TRGBCompactColor::operator*=

TRGBCompactColor & operator *= (const float aScalar)

Interface Category:

API.

Purpose:

Multiplies the components of this TRGBCompactColor 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:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::operator/=

TRGBCompactColor & operator /= (const float aScalar)

Interface Category:

API.

Purpose:

Divides the components of this TRGBCompactColor 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:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::FuzzyCompare

  1. bool FuzzyCompare (const TRGBCompactColor & aRGBCompactColor, float acceptableErrorPerComponent =0.0001) const
  2. bool FuzzyCompare (const TRGBCompactColor & aRGBCompactColor, float errOpacity, float errRed, float errGreen, float errBlue) const

Interface Category:

API.

Purpose:

  1. Compares this TRGBCompactColor 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 TRGBCompactColor and the specified color to a given accuracy on a component-by-component level.

Calling Context:

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

Parameters:

Return Value:

  1. Returns true if the two colors are equal within the specified tolerance.
  2. Returns true if the two colors are equal within the specified tolerance.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

None.

Member Function: TRGBCompactColor::LinearInterpolate

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

Interface Category:

API.

Purpose:

Makes a weighted linear interpolation of each component of this TRGBCompactColor. The interpolation is returned in this color. The interpolation that is done for each component is (using red as an example) given by red1 =red1 + (red2 -red1) * aWeight.

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: TRGBCompactColor::AddAndPin

void AddAndPin (const TRGBCompactColor & aColor2)

Interface Category:

API.

Purpose:

Adds the specified color to this TRGBCompactColor 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:

None.

Member Function: TRGBCompactColor::SubtractAndPin

void SubtractAndPin (const TRGBCompactColor & aColor2)

Interface Category:

API.

Purpose:

Subtracts the specified color from this TRGBCompactColor 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:

None.

Member Function: TRGBCompactColor::Maximum

void Maximum (const TRGBCompactColor & aColor2)

Interface Category:

API.

Purpose:

Determines the maximum of individual components of this TRGBCompactColor 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:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::Minimum

void Minimum (const TRGBCompactColor & aColor2)

Interface Category:

API.

Purpose:

Determines the minimum of individual components of this TRGBCompactColor and the specified color. It sets the components of this color to the resulting minimum values.

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: TRGBCompactColor::Blend

void Blend (const TRGBCompactColor & aColor2)

Interface Category:

API.

Purpose:

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

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::Invert

void Invert ()

Interface Category:

API.

Purpose:

Inverts this TRGBCompactColor by subtracting the values of the individual components from 255.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::Clamp

void Clamp ()

Interface Category:

API.

Purpose:

Clamps the components of this TRGBCompactColor between 0 <= N <= 255. If any value is less than 0, it is set to 0, and if it is greater than 255, it is set to 255.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::Scale

void Scale ()

Interface Category:

API.

Purpose:

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

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Multithread safe.

Other Considerations:

This function sets the opacity value to 255.

Member Function: TRGBCompactColor::TemporaryTypeID

virtual TemporaryColorClassID TemporaryTypeID () const

Interface Category:

API.

Purpose:

Returns TColor::kRGBCompactColor, an enumeration tag that identifies this class type.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns TColor::kRGBCompactColor.

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.