| Class defines a simple transform that can be applied to the color space of a graphic object.
There are two types of transform possible:
1. Multiplication Transforms
2. Addition Transforms
Multiplication transforms multiply the red, green, and blue components by an 8.8 fixed-point multiplication term.
The fixed-point representation of 1.0 is 0x100 or 256 decimal.
Therefore, the result of a multiplication operation should be divided by 256.
For any color (R,G,B,A) the transformed color (R', G', B', A') is calculated as follows:
R' = (R * RedMultTerm) / 256
G' = (G * GreenMultTerm) / 256
B' = (B * BlueMultTerm) / 256
A' = (A * AlphaMultTerm) / 256
Addition transforms simply add an addition term (positive or negative) to the red, green and blue components of
the object being displayed. If the result is greater than 255, the result is clamped to 255.
If the result is less than zero, the result is clamped to zero.
For any color (R,G,B,A) the transformed color (R', G', B', A') is calculated as follows:
R' = max(0, min(R + RedAddTerm, 255))
G' = max(0, min(G + GreenAddTerm, 255))
B' = max(0, min(B + BlueAddTerm, 255))
A' = max(0, min(A + AlphaAddTerm, 255))
Addition and Multiplication transforms can be combined as below.
The multiplication operation is performed first.
R' = max(0, min(((R * RedMultTerm) / 256) + RedAddTerm, 255))
G' = max(0, min(((G * GreenMultTerm) / 256) + GreenAddTerm, 255))
B' = max(0, min(((B * BlueMultTerm) / 256) + BlueAddTerm, 255))
A' = max(0, min(((A * AlphaMultTerm) / 256) + AlphaAddTerm, 255))
author: Dmitry Skavish |