Gaussian blur effect

Use the Gaussian blur effect to create a blur based on the Gaussian function over the entire input image.

You can use this effect to create glows and drop shadows and use the composite effect to apply the result to the original image. It is useful in photo processing for filters like highlights and shadows. You can use the output of this effect for input into lighting effects, like the Specular Lighting or Diffuse Lighting effects, because the alpha channel is blurred, too and lighting effects use the alpha channel to determine surface geometry as a height map.

This effect is used by the built-in Shadow effect.

The CLSID for this effect is CLSID_D2D1GaussianBlur.

Example image

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

 


ComPtr<ID2D1Effect> gaussianBlurEffect;
m_d2dContext->CreateEffect(CLSID_D2D1GaussianBlur, &gaussianBlurEffect);

gaussianBlurEffect->SetInput(0, bitmap);
gaussianBlurEffect->SetValue(D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, 3.0f);

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

Effect properties

Display name and index enumerationType and default valueDescription

StandardDeviation

D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION

FLOAT

3.0f

The amount of blur to be applied to the image. You can compute the blur radius of the kernel by multiplying the standard deviation by 3. The units of both the standard deviation and blur radius are DIPs. A value of zero DIPs disables this effect entirely.

Optimization

D2D1_GAUSSIANBLUR_PROP_OPTIMIZATION

D2D1_GAUSSIANBLUR_OPTIMIZATION

D2D1_GAUSSIANBLUR_OPTIMIZATION_BALANCED

The optimization mode. See Optimization modes for more info.

BorderMode

D2D1_GAUSSIANBLUR_PROP_BORDER_MODE

D2D1_GAUSSIANBLUR_BORDER_MODE

D2D1_BORDER_MODE_SOFT

The mode used to calculate the border of the image, soft or hard. See Border modes for more info.

 

Optimization modes

NameDescription
D2D1_DIRECTIONALBLUR_OPTIMIZATION_SPEEDApplies internal optimizations such as pre-scaling at relatively small radii. Uses linear filtering.
D2D1_DIRECTIONALBLUR_OPTIMIZATION_BALANCEDUses the same optimization thresholds as Speed mode, but uses trilinear filtering.
D2D1_DIRECTIONALBLUR_OPTIMIZATION_QUALITYOnly uses internal optimizations with large blur radii, where approximations are less likely to be visible. Uses trilinear filtering.

 

Border modes

NameDescription
D2D1_BORDER_MODE_SOFT

The effect pads the image with transparent black pixels as it applies the blur kernel, resulting in a soft edge.

D2D1_BORDER_MODE_HARD

The effect clamps the output to the size of the input image. When the effect applies the blur kernel, it extends the input image with a mirror-type border transform for samples outside of the input bounds.

 

Output bitmap

The output of this effect can be larger than the input bitmap based on the blur radius and the border mode. If the border mode is set to D2D1_BORDER_MODE_SOFT the size of the output bitmap increases by the size of the blur kernel, represented in pixels. This table provides an equation that you can use to compute the output bitmap.

Output bitmap growth (X and Y) = StandardDeviation (DIPs)*6*((User DPI)/96)

So, if the image size increases by 10 pixels in each direction the upper left corner of the image will be located at (-5, -5) while the lower right will be at (105, 105).

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

 

 

Community Additions

ADD
Show:
© 2014 Microsoft