Crop effect

Use the crop effect to output a specified region of an image.

The CLSID for this effect is CLSID_D2D1Crop.

Example image

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

 


ComPtr<ID2D1Effect> cropEffect;
m_d2dContext->CreateEffect(CLSID_D2D1Crop, &cropEffect);

cropEffect->SetInput(0, bitmap);
cropEffect->SetValue(D2D1_CROP_PROP_RECT, D2D1::RectF(0.0f, 0.0f, 256.0f, 192.0f));

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

Effect properties

Display name and index enumerationType and default valueDescription

Rect

D2D1_VECTOR_4F

The region to be cropped specified as a vector in the form (left, top, width, height).

D2D1_CROP_PROP_RECT

{-FLT_MAX, -FLT_MAX, FLT_MAX, FLT_MAX}

The units are in DIPs.

Note  

The Rect will be truncated if it overlaps the edge boundaries of the input image.

 

D2D1_CROP_PROP_BORDER_MODE

D2D1_BORDER_MODE

D2D1_BORDER_MODE_SOFT

  • D2D1_BORDER_MODE_SOFT : If the crop rectangle falls on fractional pixel coordinates, the effect applies antialiasing which results in a soft edge.
  • D2D1_BORDER_MODE_HARD : If the crop rectangle falls on fractional pixel coordinates, the effect clamps which results in a hard edge.

 

Output bitmap

The output of this effect is the size of the Rect property. The length and width are calc

ulated using the equations here:

Output length in Pixels=(Rect.Right-Rect.Left)*(User's DPI/96)
Output height in pixels=(Rect.Bottom-Rect.Top)*(User's DPI/96)

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: