PathGradientBrush::GetBlendCount メソッド (gdipluspath.h)

PathGradientBrush::GetBlendCount メソッドは、このパス グラデーション ブラシに現在設定されているブレンド 係数の数を取得します。

構文

INT GetBlendCount();

戻り値

型: INT

このメソッドは、このパス グラデーション ブラシに現在設定されているブレンド 係数の数を返します。

解説

PathGradientBrush オブジェクトの PathGradientBrush::GetBlend メソッドを呼び出す前に、2 つのバッファーを割り当てる必要があります。1 つはブレンド ファクターの配列を受け取り、1 つはブレンド位置の配列を受け取ります。 必要なバッファーのサイズを確認するには、PathGradientBrush オブジェクトの PathGradientBrush::GetBlendCount メソッドを呼び出します。 各バッファーのサイズ (バイト単位) は 、PathGradientBrush::GetBlendCountsizeof( REAL) を乗算した戻り値にする必要があります。

次の例では、PathGradientBrush::SetBlend、PathGradientBrush::GetBlendCount、PathGradientBrush::GetBlend など、PathGradientBrush クラスのいくつかのメソッドを示します。 このコードでは 、PathGradientBrush オブジェクトを作成し、 PathGradientBrush::SetBlend メソッドを呼び出して、ブラシのブレンド ファクターとブレンド位置のセットを確立します。 次に、 PathGradientBrush::GetBlendCount メソッドを呼び出してブレンド 係数の数を取得します。 ブレンド 係数の数が取得されると、2 つのバッファーが割り当てられます。1 つはブレンド 係数の配列を受け取り、1 つはブレンド位置の配列を受け取ります。 次に、 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 を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

関連項目

ブラシと図形の塗りつぶし

パス グラデーションの作成

色のグラデーションで図形を塗りつぶす

PathGradientBrush

PathGradientBrush::GetBlend

PathGradientBrush::SetBlend