PathGradientBrush::GetTransform 方法 (gdipluspath.h)

PathGradientBrush::GetTransform方法會取得此路徑漸層筆刷的轉換矩陣。

語法

Status GetTransform(
  [out] Matrix *matrix
);

參數

[out] matrix

類型: 矩陣*

會接收轉換矩陣之 Matrix 物件的指標。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。

備註

PathGradientBrush物件會維護可儲存任何關聯轉換的轉換矩陣。 當您使用路徑漸層筆刷填滿區域時,GDI+ 會根據筆刷的轉換矩陣轉換筆刷的界限路徑,然後填滿轉換路徑的內部。 轉換的路徑只存在於轉譯期間; 儲存在 PathGradientBrush 物件的界限路徑不會轉換。

範例

下列範例會根據三個點的陣列建立 PathGradientBrush 物件。 PathGradientBrush::ScaleTransformPathGradientBrush::TranslateTransform方法會設定筆刷轉換矩陣的元素,讓矩陣代表第一個刻度 (複合轉換,然後轉譯) 。 該複合轉換會套用至筆刷的界限路徑,因此 對 FillRectangle 的呼叫會填滿三角形的內部,這是縮放和轉譯界限路徑的結果。 此程式碼會呼叫PathGradientBrush::GetTransform物件的 PathGradientBrush方法,以取得筆刷的轉換矩陣,然後呼叫所擷取Matrix物件的GetElements方法,以使用矩陣元素填滿陣列。

VOID Example_GetTransform(HDC hdc)
{
  Graphics graphics(hdc);

   // Create a path gradient brush and set its transformation.
   Point pts[] = {Point(0, 0), Point(50, 0), Point(50, 50)};
   PathGradientBrush pthGrBrush(pts, 3);
   pthGrBrush.ScaleTransform(3.0f, 1.0f);
   pthGrBrush.TranslateTransform(10.0f, 30.0f, MatrixOrderAppend);

   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);

   // Obtain information about the path gradient brush.
   Matrix matrix;
   REAL elements[6];

   pthGrBrush.GetTransform(&matrix);
   matrix.GetElements(elements);

   for(INT j = 0; j <= 5; ++j)
   {
      // Inspect or use the value in elements[j].
   } 
}

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdipluspath.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

筆刷和填滿的圖形

建立路徑漸層

使用色彩漸層填滿圖形

矩陣

以矩陣來表示轉換

PathGradientBrush

PathGradientBrush::SetTransform

轉換