Adjusts the saturation value of a color.
D3DXCOLOR* D3DXColorAdjustSaturation( _In_ D3DXCOLOR *pOut, _In_ const D3DXCOLOR *pC, _In_ FLOAT s );
- pOut [in]
Pointer to a D3DXCOLOR that is the result of the operation.
- pC [in]
Type: const D3DXCOLOR*
Pointer to a source D3DXCOLOR structure.
- s [in]
Saturation value. This parameter linearly interpolates between the color converted to grayscale and the original color, pC. There are no limits on the value of s. If s is 0, the returned color is the grayscale color. If s is 1, the returned color is the original color.
This function returns a pointer to a D3DXCOLOR structure that is the result of the saturation adjustment.
The input alpha channel is copied, unmodified, to the output alpha channel.
The return value for this function is the same value returned in the pOut parameter. In this way, this function can be used as a parameter for another function.
This function interpolates the red, green, and blue color components of a D3DXCOLOR structure between an unsaturated color and a color, as shown in the following example.
//Approximate values for each component's contribution to luminance. //Based upon the NTSC standard described in ITU-R Recommendation BT.709. FLOAT grey = pC->r * 0.2125f + pC->g * 0.7154f + pC->b * 0.0721f; pOut->r = grey + s * (pC->r - grey);
If s is greater than 0 and less than 1, the saturation is decreased. If s is greater than 1, the saturation is increased.
The grayscale color is computed as:
r = g = b = 0.2125*r + 0.7154*g + 0.0721*b;