Редагувати

Поділитися через


Posterize effect

The posterize effect reduces the number of unique colors in an image.

The CLSID for this effect is CLSID_D2D1Posterize.

Example image

example of effect output

Sample code

ComPtr<ID2D1Effect> posterizeEffect;
m_d2dContext->CreateEffect(CLSID_D2D1Posterize, &posterizeEffect);
 
posterizeEffect->SetInput(0, bitmap);
posterizeEffect->SetValue(D2D1_POSTERIZE_PROP_RED_VALUE_COUNT, 4);
posterizeEffect->SetValue(D2D1_POSTERIZE_PROP_GREEN_VALUE_COUNT, 4);
posterizeEffect->SetValue(D2D1_POSTERIZE_PROP_BLUE_VALUE_COUNT, 4);
 
m_d2dContext->BeginDraw();
m_d2dContext->DrawImage(posterizeEffect.Get());
m_d2dContext->EndDraw();


Effect properties

The properties for the posterize effect are defined by the D2D1_POSTERIZE_PROP enumeration.

Requirements

Requirement Value
Minimum supported client Windows 10 [desktop apps | Windows Store apps]
Minimum supported server Windows 10 [desktop apps | Windows Store apps]
Header d2d1effects_2.h
Library d2d1.lib, dxguid.lib