PathGradientBrush::GetBlend 方法获取混合因子以及当前为此路径渐变画笔设置的相应混合位置。
语法
Status GetBlend(
  [out] REAL *blendFactors,
  [out] REAL *blendPositions,
  [in]  INT  count
);
parameters
[out] blendFactors
类型: REAL*
指向接收混合因子的数组的指针。
[out] blendPositions
类型: REAL*
指向接收混合位置的数组的指针。
[in] count
类型: INT
指定要检索的混合因子数的整数。 在调用 PathGradientBrush 对象的 PathGradientBrush::GetBlend 方法之前,请调用同一 PathGradientBrush 对象的 PathGradientBrush::GetBlendCount 方法以确定当前混合因子的数量。 检索的混合位置数与检索的混合因子数相同。
返回值
类型: 状态
如果该方法成功,则返回 Ok,这是 Status 枚举的元素。
如果方法失败,它将返回 Status 枚举的其他元素之一。
注解
PathGradientBrush 对象具有边界路径和中心点。 使用路径渐变画笔填充区域时,从边界路径移动到中心点时,颜色会逐渐变化。 默认情况下,颜色与距离呈线性相关,但可以通过调用 PathGradientBrush::SetBlend 方法自定义颜色与距离之间的关系。
示例
以下示例演示 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 | 
另请参阅
PathGradientBrush::GetBlendCount
PathGradientBrush::SetCenterColor
PathGradientBrush::SetCenterPoint 方法