PathGradientBrush::GetBlend 方法 (gdipluspath.h)

PathGradientBrush::GetBlend方法會取得目前為此路徑漸層筆刷設定的混合因數和對應的混合位置。

語法

Status GetBlend(
  [out] REAL *blendFactors,
  [out] REAL *blendPositions,
  [in]  INT  count
);

參數

[out] blendFactors

類型: REAL*

接收混合因數之陣列的指標。

[out] blendPositions

類型: REAL*

接收混合位置之陣列的指標。

[in] count

類型: INT

整數,指定要擷取的混合因數數目。 呼叫PathGradientBrush::GetBlend方法PathGradientBrush物件之前,請先呼叫相同PathGradientBrush::GetBlendCount方法,以判斷目前的混合因數數目。 擷取的混合位置數目與擷取的混合因數數目相同。

傳回值

類型: 狀態

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

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

備註

PathGradientBrush物件具有界限路徑和中心點。 當您使用路徑漸層筆刷填滿區域時,當您從界限路徑移至中心點時,色彩會逐漸變更。 根據預設,色彩與距離線性相關,但您可以呼叫 PathGradientBrush::SetBlend 方法來自訂色彩與距離之間的關聯性。

範例

下列範例示範 PathGradientBrush 類別的數種方法,包括 PathGradientBrush::SetBlendPathGradientBrush::GetBlendCountPathGradientBrush::GetBlend。 此程式碼會建立 PathGradientBrush 物件,並呼叫 PathGradientBrush::SetBlend 方法,以建立筆刷的混合因數和混合位置。 然後程式碼會呼叫 PathGradientBrush::GetBlendCount 方法來擷取混合因數的數目。 擷取混合因數數目之後,程式碼會配置兩個緩衝區:一個接收混合因數陣列,另一個用來接收混合位置的陣列。 然後程式碼會呼叫 PathGradientBrush::GetBlend 方法來擷取混合因數和混合位置。

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

   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);

   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);

   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));

   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);

   // Set blend factors and positions for the path gradient brush.
   REAL fac[] = {
      0.0f, 
      0.4f,     // 40 percent of the way from aqua to blue
      0.8f,     // 80 percent of the way from aqua to blue
      1.0f};

   REAL pos[] = {
      0.0f, 
      0.3f,   // 30 percent of the way from the boundary to the center
      0.7f,   // 70 percent of the way from the boundary to the center
      1.0f};

   pthGrBrush.SetBlend(fac, pos, 4);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);

   // Obtain information about the path gradient brush.
   INT blendCount = pthGrBrush.GetBlendCount();
   REAL* factors = new REAL[blendCount];
   REAL* positions = new REAL[blendCount];

   pthGrBrush.GetBlend(factors, positions, blendCount);

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

   delete [] factors;
   delete [] positions; 
}

需求

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

另請參閱

筆刷和填滿的圖形

建立路徑漸層

使用色彩漸層填滿圖形

GraphicsPath

LinearGradientBrush \(英文\)

PathGradientBrush

PathGradientBrush::GetBlendCount

PathGradientBrush::SetBlend

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint 方法

PathGradientBrush::SetSurroundColors

路徑