ID2D1RenderTarget::FillOpacityMask(ID2D1Bitmap*,ID2D1Brush*,D2D1_OPACITY_MASK_CONTENT,constD2D1_RECT_F&,constD2D1_RECT_F&) method (d2d1.h)

Applies the opacity mask described by the specified bitmap to a brush and uses that brush to paint a region of the render target.


void FillOpacityMask(
  [in]  ID2D1Bitmap               *opacityMask,
  [in]  ID2D1Brush                *brush,
        D2D1_OPACITY_MASK_CONTENT content,
  [ref] const D2D1_RECT_F &       destinationRectangle,
  [ref] const D2D1_RECT_F &       sourceRectangle


[in] opacityMask

Type: ID2D1Bitmap*

The opacity mask to apply to the brush. The alpha value of each pixel in the region specified by sourceRectangle is multiplied with the alpha value of the brush after the brush has been mapped to the area defined by destinationRectangle.

[in] brush

Type: ID2D1Brush*

The brush used to paint the region of the render target specified by destinationRectangle.



The type of content the opacity mask contains. The value is used to determine the color space in which the opacity mask is blended.

Note  Starting with Windows 8, the D2D1_OPACITY_MASK_CONTENT is not required. See the ID2D1DeviceContext::FillOpacityMask method, which has no D2D1_OPACITY_MASK_CONTENT parameter.

[ref] destinationRectangle

Type: const D2D1_RECT_F

The region of the render target to paint, in device-independent pixels.

[ref] sourceRectangle

Type: const D2D1_RECT_F

The region of the bitmap to use as the opacity mask, in device-independent pixels.

Return value



For this method to work properly, the render target must be using the D2D1_ANTIALIAS_MODE_ALIASED antialiasing mode. You can set the antialiasing mode by calling the ID2D1RenderTarget::SetAntialiasMode method.

This method doesn't return an error code if it fails. To determine whether a drawing operation (such as FillOpacityMask) failed, check the result returned by the ID2D1RenderTarget::EndDraw or ID2D1RenderTarget::Flush methods.


Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header d2d1.h
Library D2d1.lib
DLL D2d1.dll

See also