Made to Order Software Corporation Logo

libsswf: sswf::ColorTransform Class Reference

The simple color transform of a TagPlace tag. More...

#include <libsswf.h>

List of all members.


Public Member Functions

double AddAlpha (void) const
 Get the current alpha offset.
double AddBlue (void) const
 Get the current blue offset.
double AddGreen (void) const
 Get the current green offset.
double AddRed (void) const
 Get the current red offset.
 ColorTransform (void)
 Initializes a color tranformation to "no transformation".
bool IsNull (bool with_alpha) const
 Check whether this transformation has an effect.
bool IsSolidCompatible (void) const
 Check whether this color transform has no alpha.
double MultAlpha (void) const
 Get the current alpha scaling.
double MultBlue (void) const
 Get the current blue scaling.
double MultGreen (void) const
 Get the current green scaling.
double MultRed (void) const
 Get the current red scaling.
ErrorManager::error_code_t Parse (const Data &data, bool load_alpha=true)
 Parse the color transformation from a Data buffer.
void Reset (void)
 Resets the transformation to the identity matrix.
void Save (Data &data, bool save_alpha=true)
 Save the color transformation in a buffer.
void SetAdd (double red, double green, double blue, double alpha=0.0)
 Set the color offsets.
void SetMult (double red, double green, double blue, double alpha=1.0)
 Set the color scalings.

Private Attributes

double f_add_alpha
double f_add_blue
double f_add_green
double f_add_red
double f_mult_alpha
double f_mult_blue
double f_mult_green
double f_mult_red

Detailed Description

Up to version 7, only a ColorTransform can be used to change the colors of the objects. This color transformation uses a simplified matrix like this:

  | s 0 0 0 0 |
  | 0 s 0 0 0 |
  | 0 0 s 0 0 |
  | 0 0 0 s 0 |
  | o o o o 1 |

The 's' represents the scaling and it is set with sswf::ColorTranform::SetMult(double red, double green, double blue, double alpha). or one of the specific color functions. By default the scalings are set to 1.0f.

The 'o' represents the offset and it is set with sswf::ColorTranform::SetAdd(double red, double green, double blue, double alpha) or one of the specific color functions. By default the offsets are set to 0.0f.

There is no way to apply a rotation to your colors with this limited color transformation.

See also:
sswf::ColorTranform::Reset(void)

sswf::ColorTranform::SetAdd(double red, double green, double blue, double alpha)

sswf::ColorTranform::SetMult(double red, double green, double blue, double alpha)

SWF Alexis' Reference—swf_color_transform


Constructor & Destructor Documentation

ColorTransform::ColorTransform ( void   ) 

This function initializes the color transformation to no offset and no scaling of the colors.

See also:
sswf::ColorTransform::Reset(void)

References Reset().


Member Function Documentation

sswf::ColorTransform::AddAlpha ( void   )  const [inline]

This function returns the current alpha offset.

Returns:
The alpha offset.
See also:
sswf::ColorTransform::AddRed(void) const

sswf::ColorTransform::AddGreen(void) const

sswf::ColorTransform::AddBlue(void) const

References f_add_alpha.

sswf::ColorTransform::AddBlue ( void   )  const [inline]

This function returns the current blue offset.

Returns:
The blue offset.
See also:
sswf::ColorTransform::AddRed(void) const

sswf::ColorTransform::AddGreen(void) const

sswf::ColorTransform::AddAlpha(void) const

References f_add_blue.

sswf::ColorTransform::AddGreen ( void   )  const [inline]

This function returns the current green offset.

Returns:
The green offset.
See also:
sswf::ColorTransform::AddRed(void) const

sswf::ColorTransform::AddBlue(void) const

sswf::ColorTransform::AddAlpha(void) const

References f_add_green.

sswf::ColorTransform::AddRed ( void   )  const [inline]

This function returns the current red offset.

Returns:
The red offset.
See also:
sswf::ColorTransform::AddGreen(void) const

sswf::ColorTransform::AddBlue(void) const

sswf::ColorTransform::AddAlpha(void) const

References f_add_red.

bool ColorTransform::IsNull ( bool  with_alpha  )  const

This function returns true if all the offsets are zeroes (0.0f) and the scalings are all ones (1.0f).

The test is performed with the internal values transformed to 16 bits signed 8.8 fixed values. This means rounding may be applied before the test is applied.

This function is used to know whether a color transform needs to be saved in the output. A null color transform is not saved if not really necessary.

Parameters:
[in] with_alpha Whether the alpha channel is tested
Returns:
true if the color transform matrix will have no effect on the user colors.
See also:
sswf::ColorTransform::IsSolidCompatible(void) const

TagBase::Double2Signed16(double value)

References sswf::TagBase::Double2Signed16(), f_add_alpha, f_add_blue, f_add_green, f_add_red, f_mult_alpha, f_mult_blue, f_mult_green, and f_mult_red.

Referenced by sswf::TagPlace::Save().

bool ColorTransform::IsSolidCompatible ( void   )  const

This function checks whether the color transform has an alpha channel offset set to zero (0.0f) and a scaling of one (1.0f).

The test is performed with the internal values transformed to 16 bits signed 8.8 fixed values. This means rounding may be applied before the test is applied.

Returns:
true if the color transform is solid
See also:
sswf::ColorTransform::IsNull(bool with_alpha) const

TagBase::Double2Signed16(double value)

References sswf::TagBase::Double2Signed16(), f_add_alpha, and f_mult_alpha.

Referenced by sswf::TagPlace::PreSave(), and sswf::TagPlace::Save().

sswf::ColorTransform::MultAlpha ( void   )  const [inline]

This function returns the current alpha scaling.

Returns:
The alpha scaling.
See also:
sswf::ColorTransform::MultRed(void) const

sswf::ColorTransform::MultGreen(void) const

sswf::ColorTransform::MultBlue(void) const

References f_add_alpha.

sswf::ColorTransform::MultBlue ( void   )  const [inline]

This function returns the current blue scaling.

Returns:
The blue scaling.
See also:
sswf::ColorTransform::MultRed(void) const

sswf::ColorTransform::MultGreen(void) const

sswf::ColorTransform::MultAlpha(void) const

References f_add_blue.

sswf::ColorTransform::MultGreen ( void   )  const [inline]

This function returns the current green scaling.

Returns:
The green scaling.
See also:
sswf::ColorTransform::MultRed(void) const

sswf::ColorTransform::MultBlue(void) const

sswf::ColorTransform::MultAlpha(void) const

References f_add_green.

sswf::ColorTransform::MultRed ( void   )  const [inline]

This function returns the current red scaling.

Returns:
The red scaling.
See also:
sswf::ColorTransform::MultGreen(void) const

sswf::ColorTransform::MultBlue(void) const

sswf::ColorTransform::MultAlpha(void) const

References f_add_red.

ErrorManager::error_code_t ColorTransform::Parse ( const Data data,
bool  load_alpha = true 
)

This function loads the color transformation matrix from the specified Data buffer.

Parameters:
[in] data The buffer where the color transform is loaded.
[in] load_alpha Whether the alpha channel needs to be loaded.
Returns:
An error or ERROR_CODE_NONE.

References sswf::ErrorManager::ERROR_CODE_NONE, f_add_alpha, f_add_blue, f_add_green, f_add_red, f_mult_alpha, f_mult_blue, f_mult_green, f_mult_red, sswf::Data::GetBits(), sswf::Data::ReadAlign(), and sswf::TagBase::Signed162Double().

Referenced by sswf::State::Parse().

void ColorTransform::Reset ( void   ) 

This function removes the effect of any previous transformation. The offsets are set to all zeroes (0.0f) and the multiplicators are all set to 1.0f.

References f_add_alpha, f_add_blue, f_add_green, f_add_red, f_mult_alpha, f_mult_blue, f_mult_green, and f_mult_red.

Referenced by ColorTransform(), and sswf::State::Reset().

void ColorTransform::Save ( Data data,
bool  save_alpha = true 
)

This function saves the color transformation matrix in the specified data buffer.

The function ensures that the result is saved as compressed as possible. If the scalings are all ones (1.0f), then it is not saved. If the offsets are all zeroes (0.0f), then it is not saved.

The number of bits used to save the scaling and offset values is computed so the smallest possible number of bits is used.

Parameters:
[in] data The buffer where the color transform is saved
[in] save_alpha Whether the alpha channel needs to be saved

References sswf::Data::Align(), sswf::TagBase::Double2Signed16(), f_add_alpha, f_add_blue, f_add_green, f_add_red, f_mult_alpha, f_mult_blue, f_mult_green, f_mult_red, sswf::TagBase::SIBitSize(), and sswf::Data::WriteBits().

Referenced by sswf::TagPlace::Save(), and sswf::State::Save().

void ColorTransform::SetAdd ( double  red,
double  green,
double  blue,
double  alpha = 0.0 
)

This function lets you define the color offsets.

By default the offsets are all zeroes (0.0f).

Parameters:
[in] red The red offset
[in] green The green offset
[in] blue The blue offset
[in] alpha The alpha offset
See also:
ColorTransform::SetMult(double red, double green, double blue, double alpha)

References f_add_alpha, f_add_blue, f_add_green, and f_add_red.

void ColorTransform::SetMult ( double  red,
double  green,
double  blue,
double  alpha = 1.0 
)

This function lets you define the color scalings.

By default the scalings are all ones (1.0f).

Parameters:
[in] red The red scaling
[in] green The green scaling
[in] blue The blue scaling
[in] alpha The alpha scaling
See also:
ColorTransform::SetAdd(double red, double green, double blue, double alpha)

References f_mult_alpha, f_mult_blue, f_mult_green, and f_mult_red.


Member Data Documentation

Referenced by IsNull(), Parse(), Reset(), Save(), and SetMult().

Referenced by IsNull(), Parse(), Reset(), Save(), and SetMult().


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


Generated on Wed Mar 18 15:13:57 2009 for libsswf by  doxygen 1.5.5