ID2D1Factory::CreateTransformedGeometry (ID2D1Geometry*,constD2D1_MATRIX_3X2_F&,ID2D1TransformedGeometry**) 方法 (d2d1.h)

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

語法

HRESULT CreateTransformedGeometry(
  ID2D1Geometry             *sourceGeometry,
  const D2D1_MATRIX_3X2_F & transform,
  ID2D1TransformedGeometry  **transformedGeometry
);

參數

sourceGeometry

類型: [in] ID2D1Geometry*

要轉換的幾何。

transform

類型:[in] const D2D1_MATRIX_3X2_F &

要套用的轉換。

transformedGeometry

類型: [out] ID2D1TransformedGeometry**

當這個方法傳回時,會包含新轉換幾何物件的指標位址。 轉換后的幾何會藉由轉換來儲存轉換 sourceGeometry 的結果。

傳回值

類型: HRESULT

如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。

備註

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

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

範例

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

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

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

較大型矩形內具有較粗筆劃的較小矩形圖例
// 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 方法來調整幾何比例,然後繪製幾何。 它會產生下圖所示的輸出。 請注意,雖然矩形較大,但其筆劃尚未增加。

在具有相同筆劃的較大矩形內較小的矩形圖例
 // 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);

規格需求

需求
最低支援的用戶端 適用於 Windows Vista 的 Windows 7、Windows Vista SP2 和平臺更新 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 d2d1.h
程式庫 D2d1.lib
Dll D2d1.dll

另請參閱

ID2D1Factory

ID2D1TransformedGeometry