Microsoft DirectX 8.1 (Visual Basic)

D3DXColorAdjustSaturation

Adjusts the saturation value of a color.

D3DXColorAdjustSaturation( _ 
    COut As D3DCOLORVALUE, _ 
    C1 As D3DCOLORVALUE, _ 
    s As Single)

Parameters

COut
A D3DCOLORVALUE type that is the result of the operation, the result of the saturation adjustment.
C1
A source D3DCOLORVALUE type.
s
Saturation value. This parameter linearly interpolates between the color converted to gray-scale and the original color, C1. There are no limits on the value of s. If s is 0, then the returned color is the gray-scale color. If s is 1, the returned color is the original color.

Error Codes

If the function fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DERR_OUTOFVIDEOMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

This function interpolates the red, green, and blue color components of a D3DCOLORVALUE type between an unsaturated color and a color, as shown in the following example.

    ' Approximate values for each component's contribution to luminance.
    ' Based up the NTSC standard described in ITU-R Recommendation BT.709.
    Dim Grey As Long
    Grey = C1.r * 0.2125 + C1.g * 0.7154 + C1.b * 0.0721
    
    COut.r = Grey + s * (C1.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 gray-scale color is computed as: r = g = b = 0.2125*r + 0.7154*g + 0.0721*b.

See Also

D3DXColorAdjustContrast