PathGradientBrush::GetBlendCount 方法获取当前为此路径渐变画笔设置的混合因子数。
语法
INT GetBlendCount();
返回值
类型: INT
此方法返回当前为此路径渐变画笔设置的混合因子数。
注解
在调用 PathGradientBrush 对象的 PathGradientBrush::GetBlend 方法之前,必须分配两个缓冲区:一个用于接收混合因子数组,一个用于接收混合位置数组。 若要确定所需缓冲区的大小,请调用 PathGradientBrush 对象的 PathGradientBrush::GetBlendCount 方法。 每个缓冲区) 的大小 (应为 PathGradientBrush::GetBlendCount 的返回值乘以 sizeof ( REAL) 。
示例
以下示例演示 PathGradientBrush 类的几种方法,包括 PathGradientBrush::SetBlend、 PathGradientBrush::GetBlendCount 和 PathGradientBrush::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) | 
| Library | Gdiplus.lib | 
| DLL | Gdiplus.dll |