Saturation effect

Use this effect to alter the saturation of an image. The saturation effect is a specialization of the color matrix effect.

The CLSID for this effect is CLSID_D2D1Saturation.

Example image

The example here shows the input and output images of the saturation effect with a saturation of 0%.

Before
The image before the effect.
After
The image after the transform.

 


ComPtr<ID2D1Effect> saturationEffect;
m_d2dContext->CreateEffect(CLSID_D2D1Saturation, &saturationEffect);

saturationEffect->SetInput(0, bitmap);

saturationEffect->SetValue(D2D1_SATURATION_PROP_SATURATION, 0.0f);

m_d2dContext->BeginDraw();
m_d2dContext->DrawImage(saturationEffect.Get());
m_d2dContext->EndDraw();

The effect calculates a color matrix based on the saturation value (s in the equation here) you specify with the D2D1_SATURATION_PROP_SATURATION property. The matrix equation is shown here.

Formula for calculating a saturation matrix.

The matrix created depends only on the saturation value. You can use the color matrix effect if you need a specific matrix.

This effect consumes and outputs premultiplied alpha images. The effect won't work on straight alpha images unless they are fully opaque.

Effect properties

Display name and index enumerationType and default valueDescription

Saturation

D2D1_SATURATION_PROP_SATURATION

FLOAT

0.5f

The saturation of the image. You can set the saturation to a value between 0 and 1. If you set it to 1 the output image is fully saturated. If you set it to 0 the output image is monochrome. The saturation value is unitless.

 

Requirements

Minimum supported clientWindows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Minimum supported serverWindows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Headerd2d1effects.h
Libraryd2d1.lib, dxguid.lib

 

Related topics

ID2D1Effect

 

 

Show: