Edit

Share via


Border effect

Use the border effect to extend an image from the edges. You can use this effect to repeat the pixels from the edges of the image, wrap the pixels from the opposite end of the image, or mirror the pixels across the bitmap border to extend the bitmap region.

The CLSID for this effect is CLSID_D2D1Border.

Example images

The examples here show the output of the border effect using each mode. The output size is infinite, but these example images are cropped to twice the size.

Mirror

Before
Screenshot that shows the image before the effect.
After
Screenshot that shows the image after the transform.

Clamp

Before
Screenshot that shows the image before the effect for a clamp.
After
Screenshot that shows the image after the transform for a clamp.

Wrap

Before
Screenshot that shows the image before the effect for a wrap.
After
Screenshot that shows the image after the transform for a wrap.
ComPtr<ID2D1Effect> borderEffect;
m_d2dContext->CreateEffect(CLSID_D2D1Border, &borderEffect);

borderEffect->SetInput(0, bitmap);
borderEffect->SetValue(D2D1_BORDER_PROP_EDGE_MODE_X, D2D1_BORDER_EDGE_MODE_MIRROR);
borderEffect->SetValue(D2D1_BORDER_PROP_EDGE_MODE_Y, D2D1_BORDER_EDGE_MODE_MIRROR);

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

Effect properties

Display name and index enumeration Description
Edge Mode X
D2D1_BORDER_PROP_EDGE_MODE_X
The edge mode in the X direction for the effect. You can set this to clamp, wrap, or mirror. See Edge modes for more info.
The type is D2D1_BORDER_EDGE_MODE.
The default value is D2D1_BORDER_EDGE_MODE_CLAMP.
Edge Mode Y
D2D1_BORDER_PROP_EDGE_MODE_Y
The edge mode in the Y direction for the effect. You can set this to clamp, wrap, or mirror. See Edge modes for more info.
The type is D2D1_BORDER_EDGE_MODE.
The default value is D2D1_BORDER_EDGE_MODE_CLAMP.

Edge modes

Display name and index enumeration Description
Clamp
D2D1_BORDER_EDGE_MODE_CLAMP
Repeats the pixels from the edges of the image.
Wrap
D2D1_BORDER_EDGE_MODE_WRAP
Uses pixels from the opposite end edge of the image.
Mirror
D2D1_BORDER_EDGE_MODE_MIRROR
Reflects pixels about the edge of the image.

Output bitmap

The output bitmap size is infinite for all inputs, except a 0 sized input image. If the height or the width of an input image is 0, the output size is 0.

Requirements

Requirement Value
Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Minimum supported server Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Header d2d1effects.h
Library d2d1.lib, dxguid.lib

ID2D1Effect