Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID2D1TransformedGeometry interface

Represents a geometry that has been transformed.

When to implement

Custom implementations are not supported.


The ID2D1TransformedGeometry interface inherits from ID2D1Geometry. ID2D1TransformedGeometry also has these types of members:


The ID2D1TransformedGeometry interface has these methods.


Retrieves the source geometry of this transformed geometry object.


Retrieves the matrix used to transform the ID2D1TransformedGeometry object's source geometry.



Using an ID2D1TransformedGeometry rather than transforming a geometry by using a render target's transform enables you to transform a geometry without transforming its stroke.

Creating ID2D1TransformedGeometry Objects

To create an ID2D1TransformedGeometry, call the ID2D1Factory::CreateTransformedGeometry method.

Direct2D geometries are immutable and device-independent resources created by ID2D1Factory. In general, you should create geometries once and retain them for the life of the application, or until they need to be modified. For more information about device-independent and device-dependent resources, see the Resources Overview.


The following example creates an ID2D1RectangleGeometry, then draws it without transforming it. It produces the output shown in the following illustration.

Illustration of a rectangle

hr = m_pD2DFactory->CreateRectangleGeometry(
    D2D1::RectF(150.f, 150.f, 200.f, 200.f),

The next example uses the render target to scale the geometry by a factor of 3, then draws it. The following illustration shows the result of drawing the rectangle without the transform and with the transform; notices that the stroke is thicker after the transform, even though the stroke thickness is 1.

Illustration of a smaller rectangle inside a larger rectangle with a thicker stroke

// Transform the render target, then draw the rectangle geometry again.
        D2D1::SizeF(3.f, 3.f),
        D2D1::Point2F(175.f, 175.f))

m_pRenderTarget->DrawGeometry(m_pRectangleGeometry, m_pBlackBrush, 1);

The next example uses the CreateTransformedGeometry method to scale the geometry by a factor of 3, then draws it. It produces the output shown in the following illustration. Notice that, although the rectangle is larger, its stroke hasn't increased.

Illustration of a smaller rectangle inside a larger rectangle with the same stroke

 // Create a geometry that is a scaled version
 // of m_pRectangleGeometry.
 // The new geometry is scaled by a factory of 3
 // from the center of the geometry, (35, 35).

 hr = m_pD2DFactory->CreateTransformedGeometry(
         D2D1::SizeF(3.f, 3.f),
         D2D1::Point2F(175.f, 175.f)),

// Replace the previous render target transform.

// Draw the transformed geometry.
m_pRenderTarget->DrawGeometry(m_pTransformedGeometry, m_pBlackBrush, 1);


Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]







See also




© 2017 Microsoft