#include <libsswf.h>
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 |
| 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.
sswf::ColorTranform::SetAdd(double red, double green, double blue, double alpha)
sswf::ColorTranform::SetMult(double red, double green, double blue, double alpha)
ColorTransform::ColorTransform | ( | void | ) |
This function initializes the color transformation to no offset and no scaling of the colors.
References Reset().
sswf::ColorTransform::AddAlpha | ( | void | ) | const [inline] |
This function returns the current alpha offset.
References f_add_alpha.
sswf::ColorTransform::AddBlue | ( | void | ) | const [inline] |
This function returns the current blue offset.
References f_add_blue.
sswf::ColorTransform::AddGreen | ( | void | ) | const [inline] |
This function returns the current green offset.
References f_add_green.
sswf::ColorTransform::AddRed | ( | void | ) | const [inline] |
This function returns the current red offset.
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.
[in] | with_alpha | Whether the alpha channel is tested |
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.
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.
References f_add_alpha.
sswf::ColorTransform::MultBlue | ( | void | ) | const [inline] |
This function returns the current blue scaling.
References f_add_blue.
sswf::ColorTransform::MultGreen | ( | void | ) | const [inline] |
This function returns the current green scaling.
References f_add_green.
sswf::ColorTransform::MultRed | ( | void | ) | const [inline] |
This function returns the current red scaling.
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.
[in] | data | The buffer where the color transform is loaded. |
[in] | load_alpha | Whether the alpha channel needs to be loaded. |
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.
[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).
[in] | red | The red offset |
[in] | green | The green offset |
[in] | blue | The blue offset |
[in] | alpha | The alpha offset |
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).
[in] | red | The red scaling |
[in] | green | The green scaling |
[in] | blue | The blue scaling |
[in] | alpha | The alpha scaling |
References f_mult_alpha, f_mult_blue, f_mult_green, and f_mult_red.
double sswf::ColorTransform::f_add_alpha [private] |
Referenced by AddAlpha(), IsNull(), IsSolidCompatible(), MultAlpha(), Parse(), Reset(), Save(), and SetAdd().
double sswf::ColorTransform::f_add_blue [private] |
double sswf::ColorTransform::f_add_green [private] |
Referenced by AddGreen(), IsNull(), MultGreen(), Parse(), Reset(), Save(), and SetAdd().
double sswf::ColorTransform::f_add_red [private] |
double sswf::ColorTransform::f_mult_alpha [private] |
double sswf::ColorTransform::f_mult_blue [private] |
double sswf::ColorTransform::f_mult_green [private] |
double sswf::ColorTransform::f_mult_red [private] |