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

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

構文

INT GetInterpolationColorCount();

戻り値

型: INT

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

注釈

単純なパス グラデーション ブラシには、境界の色と中心の色の 2 つの色があります。 このようなブラシでペイントすると、境界パスから中心点に移動すると、色が境界色から中心色に徐々に変化します。 より複雑なグラデーションを作成するには、事前設定された色の配列とブレンド位置の配列を指定します。

PathGradientBrush オブジェクトに対して現在設定されている補間色と補間位置を取得するには、そのPathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColors メソッドを呼び出します。 PathGradientBrush::GetInterpolationColors メソッドを呼び出す前に、補間色の配列を保持するバッファーと補間位置の配列を保持するバッファーの 2 つを割り当てる必要があります。 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColorCount メソッドを呼び出して、これらのバッファーの必要なサイズを決定できます。 カラー バッファーのサイズは、 GetInterpolationColorCount の戻り値に sizeof(Color) を乗算した値です。 位置バッファーのサイズは、 PathGradientBrush::GetInterpolationColorCountsizeof( REAL) を乗算した値です。

次の例では、三角形の パスから PathGradientBrush オブジェクトを作成します。 このコードでは、プリセットの色を赤、青、アクアに設定し、ブレンド位置を 0、0.6、1 に設定します。 このコードでは、 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColorCount メソッドを呼び出して ブラシに現在設定されているプリセットカラーの数を取得します。 次に、コードは 2 つのバッファーを割り当てます。1 つはプリセットカラーの配列を保持し、1 つはブレンド位置の配列を保持します。 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColors メソッドを呼び出すと、バッファーにプリセットの色とブレンド位置が設定されます。 最後に、コードは、各プリセットの色で小さな正方形を塗りつぶします。

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

   // Create a path gradient brush from an array of points, and
   // set the interpolation colors for that brush.

   Point points[] = {Point(100, 0), Point(200, 200), Point(0, 200)};
   PathGradientBrush pthGrBrush(points, 3);

   Color col[] = {
      Color(255, 255, 0, 0),     // red
      Color(255, 0, 0, 255),     // blue
      Color(255, 0, 255, 255)};  // aqua

   REAL pos[] = {
      0.0f,    // red at the boundary
      0.6f,    // blue 60 percent of the way from the boundary to the center
      1.0f};   // aqua at the center

   pthGrBrush.SetInterpolationColors(col, pos, 3);

   // Obtain information about the path gradient brush.
   INT colorCount = pthGrBrush.GetInterpolationColorCount();
   Color* colors = new Color[colorCount];
   REAL* positions = new REAL[colorCount];
   pthGrBrush.GetInterpolationColors(colors, positions, colorCount);

   // Fill a small square with each of the interpolation colors.
   SolidBrush solidBrush(Color(255, 255, 255, 255));

   for(INT j = 0; j < colorCount; ++j)
   {
      solidBrush.SetColor(colors[j]);
      graphics.FillRectangle(&solidBrush, 15*j, 0, 10, 10);
   }

   delete [] colors;
   delete [] positions; 
}

要件

要件
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdipluspath.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

こちらもご覧ください

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

Color

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

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

PathGradientBrush

PathGradientBrush::GetInterpolationColors

PathGradientBrush::SetInterpolationColors