Редагувати

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


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 enumeration Type and default value Description
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

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