ID2D1Factory::CreateTransformedGeometry 方法

轉換指定的幾何,並將結果儲存為 ID2D1TransformedGeometry 物件。

多載清單

方法 描述
CreateTransformedGeometry(ID2D1Geometry*,D2D_MATRIX_3X2_F*,ID2D1TransformedGeometry**) 轉換指定的幾何,並將結果儲存為 ID2D1TransformedGeometry 物件。
CreateTransformedGeometry(ID2D1Geometry*,D2D_MATRIX_3X2_F&,ID2D1TransformedGeometry**) 轉換指定的幾何,並將結果儲存為 ID2D1TransformedGeometry 物件。

備註

與其他資源一樣,已轉換的幾何會繼承建立它之處理站的資源空間和線程原則。 這個物件是不可變的。

使用 DrawGeometry 方法繪製已轉換的幾何時,筆劃寬度不會受到套用至幾何的轉換影響。 筆劃寬度只會受到世界轉換的影響。

範例

下列範例會 建立ID2D1RectangleGeometry,然後繪製它而不轉換它。 其會產生下圖所示的輸出。

illustration of a rectangle

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

下一個範例會使用轉譯目標,將幾何縮放比例為 3,然後繪製它。 下圖顯示不使用轉換和轉換繪製矩形的結果;請注意,即使筆劃粗細為 1,轉換之後的筆劃也會更厚。

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

// Transform the render target, then draw the rectangle geometry again.
m_pRenderTarget->SetTransform(
    D2D1::Matrix3x2F::Scale(
        D2D1::SizeF(3.f, 3.f),
        D2D1::Point2F(175.f, 175.f))
    );

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

下一個範例會使用 CreateTransformedGeometry 方法,將幾何縮放比例為 3,然後繪製幾何。 其會產生下圖所示的輸出。 請注意,雖然矩形較大,但其筆劃並未增加。

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(
     m_pRectangleGeometry,
     D2D1::Matrix3x2F::Scale(
         D2D1::SizeF(3.f, 3.f),
         D2D1::Point2F(175.f, 175.f)),
     &m_pTransformedGeometry
     );


// Replace the previous render target transform.
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());

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

需求

需求
頁首
D2d1.h
程式庫
D2d1.lib
DLL
D2d1.dll

另請參閱

ID2D1Factory