共用方式為


LinearGradientBrush::SetTransform 方法 (gdiplusbrush.h)

LinearGradientBrush::SetTransform 方法會設定此線性漸層筆刷的轉換矩陣。

語法

Status SetTransform(
  [in] const Matrix *matrix
);

參數

[in] matrix

類型: const Matrix*

指定轉換矩陣之 Matrix 物件的指標。

傳回值

類型: 狀態

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

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

備註

LinearGradientBrush 物件有一個矩形,指定漸層的開始和結束界限,以及影響方向的模式或角度。 如果筆刷的轉換矩陣設定為代表身分識別以外的任何轉換,則在轉譯期間會根據該矩陣轉換界限和方向。

轉換僅適用於轉譯期間。 LinearGradientBrush 物件所儲存的界限不會由LinearGradientBrush::SetTransform 方法改變。

範例

下列範例會建立線性漸層筆刷,並使用它來填滿矩形。 接下來,程式代碼會修改筆刷的轉換矩陣,並以轉換的筆刷填滿矩形。

VOID Example_SetTransform(HDC hdc)
{
   Graphics myGraphics(hdc);

   LinearGradientBrush linGrBrush( 
      Rect(0, 0, 100, 50),
      Color(255, 255, 0, 0),  // red
      Color(255, 0, 0, 255),  // blue
      LinearGradientModeHorizontal);

   Matrix matrix(2.0, 0, 0, 1, 0, 0);  // horizontal doubling

   // Fill a large area with the linear gradient brush (no transformation).
   myGraphics.FillRectangle(&linGrBrush, 0, 0, 800, 50);

   linGrBrush.SetTransform(&matrix);

   // Fill a large area with the transformed linear gradient brush.
   myGraphics.FillRectangle(&linGrBrush, 0, 75, 800, 50);
}

規格需求

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

另請參閱

筆刷和填滿的圖形

建立線性漸層

使用漸層筆刷填滿圖形

LinearGradientBrush \(英文\)

LinearGradientBrush::GetTransform

LinearGradientBrush::ResetTransform

矩陣

以矩陣來表示轉換

Rect

轉換